OpenCoverage

build.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/build.c
Source codeSwitch to Preprocessed file
LineSourceCount
1/*-
2** 2001 September 15-
3**-
4** The author disclaims copyright to this source code. In place of-
5** a legal notice, here is a blessing:-
6**-
7** May you do good and not evil.-
8** May you find forgiveness for yourself and forgive others.-
9** May you share freely, never taking more than you give.-
10**-
11*************************************************************************-
12** This file contains C code routines that are called by the SQLite parser-
13** when syntax rules are reduced. The routines in this file handle the-
14** following kinds of SQL syntax:-
15**-
16** CREATE TABLE-
17** DROP TABLE-
18** CREATE INDEX-
19** DROP INDEX-
20** creating ID lists-
21** BEGIN TRANSACTION-
22** COMMIT-
23** ROLLBACK-
24*/-
25#include "sqliteInt.h"-
26-
27#ifndef SQLITE_OMIT_SHARED_CACHE-
28/*-
29** The TableLock structure is only used by the sqlite3TableLock() and-
30** codeTableLocks() functions.-
31*/-
32struct TableLock {-
33 int iDb; /* The database containing the table to be locked */-
34 int iTab; /* The root page of the table to be locked */-
35 u8 isWriteLock; /* True for write lock. False for a read lock */-
36 const char *zLockName; /* Name of the table */-
37};-
38-
39/*-
40** Record the fact that we want to lock a table at run-time. -
41**-
42** The table to be locked has root page iTab and is found in database iDb.-
43** A read or a write lock can be taken depending on isWritelock.-
44**-
45** This routine just records the fact that the lock is desired. The-
46** code to make the lock occur is generated by a later call to-
47** codeTableLocks() which occurs during sqlite3FinishCoding().-
48*/-
49void sqlite3TableLock(-
50 Parse *pParse, /* Parsing context */-
51 int iDb, /* Index of the database containing the table to lock */-
52 int iTab, /* Root page number of the table to be locked */-
53 u8 isWriteLock, /* True for a write lock */-
54 const char *zName /* Name of the table to be locked */-
55){-
56 Parse *pToplevel = sqlite3ParseToplevel(pParse);
(pParse)->pToplevelDescription
TRUEevaluated 6851 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 398102 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
6851-398102
57 int i;-
58 int nBytes;-
59 TableLock *p;-
60 assert( iDb>=0 );-
61-
62 if( iDb==1 ) return;
executed 12617 times by 12 tests: return;
Executed by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
iDb==1Description
TRUEevaluated 12617 times by 12 tests
Evaluated by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
FALSEevaluated 392336 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
12617-392336
63 if( !sqlite3BtreeSharable(pParse->db->aDb[iDb].pBt) ) return;
executed 390157 times by 435 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
!sqlite3BtreeS...>aDb[iDb].pBt)Description
TRUEevaluated 390157 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 2179 times by 1 test
Evaluated by:
  • Self test (438)
2179-390157
64 for(i=0; i<pToplevel->nTableLock; i++){
i<pToplevel->nTableLockDescription
TRUEevaluated 744 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1594 times by 1 test
Evaluated by:
  • Self test (438)
744-1594
65 p = &pToplevel->aTableLock[i];-
66 if( p->iDb==iDb && p->iTab==iTab ){
p->iDb==iDbDescription
TRUEevaluated 653 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 91 times by 1 test
Evaluated by:
  • Self test (438)
p->iTab==iTabDescription
TRUEevaluated 585 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 68 times by 1 test
Evaluated by:
  • Self test (438)
68-653
67 p->isWriteLock = (p->isWriteLock || isWriteLock);
p->isWriteLockDescription
TRUEevaluated 572 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
isWriteLockDescription
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-572
68 return;
executed 585 times by 1 test: return;
Executed by:
  • Self test (438)
585
69 }-
70 }
executed 159 times by 1 test: end of block
Executed by:
  • Self test (438)
159
71-
72 nBytes = sizeof(TableLock) * (pToplevel->nTableLock+1);-
73 pToplevel->aTableLock =-
74 sqlite3DbReallocOrFree(pToplevel->db, pToplevel->aTableLock, nBytes);-
75 if( pToplevel->aTableLock ){
pToplevel->aTableLockDescription
TRUEevaluated 1594 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-1594
76 p = &pToplevel->aTableLock[pToplevel->nTableLock++];-
77 p->iDb = iDb;-
78 p->iTab = iTab;-
79 p->isWriteLock = isWriteLock;-
80 p->zLockName = zName;-
81 }else{
executed 1594 times by 1 test: end of block
Executed by:
  • Self test (438)
1594
82 pToplevel->nTableLock = 0;-
83 sqlite3OomFault(pToplevel->db);-
84 }
never executed: end of block
0
85}-
86-
87/*-
88** Code an OP_TableLock instruction for each table locked by the-
89** statement (configured by calls to sqlite3TableLock()).-
90*/-
91static void codeTableLocks(Parse *pParse){-
92 int i;-
93 Vdbe *pVdbe; -
94-
95 pVdbe = sqlite3GetVdbe(pParse);-
96 assert( pVdbe!=0 ); /* sqlite3GetVdbe cannot fail: VDBE already allocated */-
97-
98 for(i=0; i<pParse->nTableLock; i++){
i<pParse->nTableLockDescription
TRUEevaluated 1594 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 299991 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1594-299991
99 TableLock *p = &pParse->aTableLock[i];-
100 int p1 = p->iDb;-
101 sqlite3VdbeAddOp4(pVdbe, OP_TableLock, p1, p->iTab, p->isWriteLock,-
102 p->zLockName, P4_STATIC);-
103 }
executed 1594 times by 1 test: end of block
Executed by:
  • Self test (438)
1594
104}
executed 299991 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
299991
105#else-
106 #define codeTableLocks(x)-
107#endif-
108-
109/*-
110** Return TRUE if the given yDbMask object is empty - if it contains no-
111** 1 bits. This routine is used by the DbMaskAllZero() and DbMaskNotZero()-
112** macros when SQLITE_MAX_ATTACHED is greater than 30.-
113*/-
114#if SQLITE_MAX_ATTACHED>30-
115int sqlite3DbMaskAllZero(yDbMask m){-
116 int i;-
117 for(i=0; i<sizeof(yDbMask); i++) if( m[i] ) return 0;-
118 return 1;-
119}-
120#endif-
121-
122/*-
123** This routine is called after a single SQL statement has been-
124** parsed and a VDBE program to execute that statement has been-
125** prepared. This routine puts the finishing touches on the-
126** VDBE program and resets the pParse structure for the next-
127** parse.-
128**-
129** Note that if an error occurred, it might be the case that-
130** no VDBE code was generated.-
131*/-
132void sqlite3FinishCoding(Parse *pParse){-
133 sqlite3 *db;-
134 Vdbe *v;-
135-
136 assert( pParse->pToplevel==0 );-
137 db = pParse->db;-
138 if( pParse->nested ) return;
executed 41295 times by 33 tests: return;
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
pParse->nestedDescription
TRUEevaluated 41295 times by 33 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
FALSEevaluated 455292 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
41295-455292
139 if( db->mallocFailed || pParse->nErr ){
db->mallocFailedDescription
TRUEevaluated 2131 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 453161 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pParse->nErrDescription
TRUEevaluated 1621 times by 13 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 451540 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1621-453161
140 if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
executed 1345 times by 1 test: pParse->rc = 1;
Executed by:
  • Self test (438)
pParse->rc==0Description
TRUEevaluated 1345 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2407 times by 13 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1345-2407
141 return;
executed 3752 times by 13 tests: return;
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
3752
142 }-
143-
144 /* Begin by generating some termination code at the end of the-
145 ** vdbe program-
146 */-
147 v = sqlite3GetVdbe(pParse);-
148 assert( !pParse->isMultiWrite -
149 || sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));-
150 if( v ){
vDescription
TRUEevaluated 451512 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
28-451512
151 sqlite3VdbeAddOp0(v, OP_Halt);-
152-
153#if SQLITE_USER_AUTHENTICATION-
154 if( pParse->nTableLock>0 && db->init.busy==0 ){-
155 sqlite3UserAuthInit(db);-
156 if( db->auth.authLevel<UAUTH_User ){-
157 sqlite3ErrorMsg(pParse, "user not authenticated");-
158 pParse->rc = SQLITE_AUTH_USER;-
159 return;-
160 }-
161 }-
162#endif-
163-
164 /* The cookie mask contains one bit for each database file open.-
165 ** (Bit 0 is for main, bit 1 is for temp, and so forth.) Bits are-
166 ** set for each database that is used. Generate code to start a-
167 ** transaction on each used database and to verify the schema cookie-
168 ** on each used database.-
169 */-
170 if( db->mallocFailed==0
db->mallocFailed==0Description
TRUEevaluated 451484 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
28-451484
171 && (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)
(pParse->cookieMask)!=0Description
TRUEevaluated 238195 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 213289 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pParse->pConstExprDescription
TRUEevaluated 61796 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 151493 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
61796-238195
172 ){-
173 int iDb, i;-
174 assert( sqlite3VdbeGetOp(v, 0)->opcode==OP_Init );-
175 sqlite3VdbeJumpHere(v, 0);-
176 for(iDb=0; iDb<db->nDb; iDb++){
iDb<db->nDbDescription
TRUEevaluated 628588 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 299991 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
299991-628588
177 Schema *pSchema;-
178 if( DbMaskTest(pParse->cookieMask, iDb)==0 ) continue;
executed 382291 times by 435 tests: continue;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
(((pParse->coo...(iDb)))!=0)==0Description
TRUEevaluated 382291 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 246297 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
246297-382291
179 sqlite3VdbeUsesBtree(v, iDb);-
180 pSchema = db->aDb[iDb].pSchema;-
181 sqlite3VdbeAddOp4Int(v,-
182 OP_Transaction, /* Opcode */-
183 iDb, /* P1 */-
184 DbMaskTest(pParse->writeMask,iDb), /* P2 */-
185 pSchema->schema_cookie, /* P3 */-
186 pSchema->iGeneration /* P4 */-
187 );-
188 if( db->init.busy==0 ) sqlite3VdbeChangeP5(v, 1);
executed 207979 times by 430 tests: sqlite3VdbeChangeP5(v, 1);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
db->init.busy==0Description
TRUEevaluated 207979 times by 430 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 38318 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
38318-207979
189 VdbeComment((v,-
190 "usesStmtJournal=%d", pParse->mayAbort && pParse->isMultiWrite));-
191 }
executed 246297 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
246297
192#ifndef SQLITE_OMIT_VIRTUALTABLE-
193 for(i=0; i<pParse->nVtabLock; i++){
i<pParse->nVtabLockDescription
TRUEevaluated 659 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 299991 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
659-299991
194 char *vtab = (char *)sqlite3GetVTable(db, pParse->apVtabLock[i]);-
195 sqlite3VdbeAddOp4(v, OP_VBegin, 0, 0, 0, vtab, P4_VTAB);-
196 }
executed 659 times by 1 test: end of block
Executed by:
  • Self test (438)
659
197 pParse->nVtabLock = 0;-
198#endif-
199-
200 /* Once all the cookies have been verified and transactions opened, -
201 ** obtain the required table-locks. This is a no-op unless the -
202 ** shared-cache feature is enabled.-
203 */-
204 codeTableLocks(pParse);-
205-
206 /* Initialize any AUTOINCREMENT data structures required.-
207 */-
208 sqlite3AutoincrementBegin(pParse);-
209-
210 /* Code constant expressions that where factored out of inner loops */-
211 if( pParse->pConstExpr ){
pParse->pConstExprDescription
TRUEevaluated 129600 times by 389 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 170391 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
129600-170391
212 ExprList *pEL = pParse->pConstExpr;-
213 pParse->okConstFactor = 0;-
214 for(i=0; i<pEL->nExpr; i++){
i<pEL->nExprDescription
TRUEevaluated 266281 times by 389 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
FALSEevaluated 129600 times by 389 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
129600-266281
215 sqlite3ExprCode(pParse, pEL->a[i].pExpr, pEL->a[i].u.iConstExprReg);-
216 }
executed 266281 times by 389 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
266281
217 }
executed 129600 times by 389 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • ...
129600
218-
219 /* Finally, jump back to the beginning of the executable code. */-
220 sqlite3VdbeGoto(v, 1);-
221 }
executed 299991 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
299991
222 }
executed 451512 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
451512
223-
224-
225 /* Get the VDBE program ready for execution-
226 */-
227 if( v && pParse->nErr==0 && !db->mallocFailed ){
vDescription
TRUEevaluated 451512 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
pParse->nErr==0Description
TRUEevaluated 451510 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
!db->mallocFailedDescription
TRUEevaluated 451478 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 32 times by 1 test
Evaluated by:
  • Self test (438)
2-451512
228 /* A minimum of one cursor is required if autoincrement is used-
229 * See ticket [a696379c1f08866] */-
230 if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
executed 1 time by 1 test: pParse->nTab = 1;
Executed by:
  • Self test (438)
pParse->pAinc!=0Description
TRUEevaluated 85 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 451393 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pParse->nTab==0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 84 times by 1 test
Evaluated by:
  • Self test (438)
1-451393
231 sqlite3VdbeMakeReady(v, pParse);-
232 pParse->rc = SQLITE_DONE;-
233 }else{
executed 451478 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
451478
234 pParse->rc = SQLITE_ERROR;-
235 }
executed 62 times by 1 test: end of block
Executed by:
  • Self test (438)
62
236}-
237-
238/*-
239** Run the parser and code generator recursively in order to generate-
240** code for the SQL statement given onto the end of the pParse context-
241** currently under construction. When the parser is run recursively-
242** this way, the final OP_Halt is not appended and other initialization-
243** and finalization steps are omitted because those are handling by the-
244** outermost parser.-
245**-
246** Not everything is nestable. This facility is designed to permit-
247** INSERT, UPDATE, and DELETE operations against SQLITE_MASTER. Use-
248** care if you decide to try to use this routine for some other purposes.-
249*/-
250void sqlite3NestedParse(Parse *pParse, const char *zFormat, ...){-
251 va_list ap;-
252 char *zSql;-
253 char *zErrMsg = 0;-
254 sqlite3 *db = pParse->db;-
255 char saveBuf[PARSE_TAIL_SZ];-
256-
257 if( pParse->nErr ) return;
executed 14 times by 1 test: return;
Executed by:
  • Self test (438)
pParse->nErrDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 41340 times by 33 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
14-41340
258 assert( pParse->nested<10 ); /* Nesting should only be of limited depth */-
259 va_start(ap, zFormat);-
260 zSql = sqlite3VMPrintf(db, zFormat, ap);-
261 va_end(ap);-
262 if( zSql==0 ){
zSql==0Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 41312 times by 33 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
28-41312
263 return; /* A malloc must have failed */
executed 28 times by 1 test: return;
Executed by:
  • Self test (438)
28
264 }-
265 pParse->nested++;-
266 memcpy(saveBuf, PARSE_TAIL(pParse), PARSE_TAIL_SZ);-
267 memset(PARSE_TAIL(pParse), 0, PARSE_TAIL_SZ);-
268 sqlite3RunParser(pParse, zSql, &zErrMsg);-
269 sqlite3DbFree(db, zErrMsg);-
270 sqlite3DbFree(db, zSql);-
271 memcpy(PARSE_TAIL(pParse), saveBuf, PARSE_TAIL_SZ);-
272 pParse->nested--;-
273}
executed 41312 times by 33 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
41312
274-
275#if SQLITE_USER_AUTHENTICATION-
276/*-
277** Return TRUE if zTable is the name of the system table that stores the-
278** list of users and their access credentials.-
279*/-
280int sqlite3UserAuthTable(const char *zTable){-
281 return sqlite3_stricmp(zTable, "sqlite_user")==0;-
282}-
283#endif-
284-
285/*-
286** Locate the in-memory structure that describes a particular database-
287** table given the name of that table and (optionally) the name of the-
288** database containing the table. Return NULL if not found.-
289**-
290** If zDatabase is 0, all databases are searched for the table and the-
291** first matching table is returned. (No checking for duplicate table-
292** names is done.) The search order is TEMP first, then MAIN, then any-
293** auxiliary databases added using the ATTACH command.-
294**-
295** See also sqlite3LocateTable().-
296*/-
297Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){-
298 Table *p = 0;-
299 int i;-
300-
301 /* All mutexes are required for schema access. Make sure we hold them. */-
302 assert( zDatabase!=0 || sqlite3BtreeHoldsAllMutexes(db) );-
303#if SQLITE_USER_AUTHENTICATION-
304 /* Only the admin user is allowed to know that the sqlite_user table-
305 ** exists */-
306 if( db->auth.authLevel<UAUTH_Admin && sqlite3UserAuthTable(zName)!=0 ){-
307 return 0;-
308 }-
309#endif-
310 while(1){-
311 for(i=OMIT_TEMPDB; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 2507495 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 149986 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
149986-2507495
312 int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
(i<2)Description
TRUEevaluated 2461431 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 46064 times by 12 tests
Evaluated by:
  • Self test (27)
  • Self test (34)
  • Self test (4)
  • Self test (438)
  • Self test (5)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
46064-2461431
313 if( zDatabase==0 || sqlite3StrICmp(zDatabase, db->aDb[j].zDbSName)==0 ){
zDatabase==0Description
TRUEevaluated 963531 times by 420 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1543964 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
sqlite3StrICmp...].zDbSName)==0Description
TRUEevaluated 751826 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 792138 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
751826-1543964
314 assert( sqlite3SchemaMutexHeld(db, j, 0) );-
315 p = sqlite3HashFind(&db->aDb[j].pSchema->tblHash, zName);-
316 if( p ) return p;
executed 1084288 times by 435 tests: return p;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pDescription
TRUEevaluated 1084288 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 631069 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
631069-1084288
317 }
executed 631069 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
631069
318 }
executed 1423207 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1423207
319 /* Not found. If the name we were looking for was temp.sqlite_master-
320 ** then change the name to sqlite_temp_master and try again. */-
321 if( sqlite3StrICmp(zName, MASTER_NAME)!=0 ) break;
executed 126674 times by 435 tests: break;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
sqlite3StrICmp...te_master")!=0Description
TRUEevaluated 126674 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 23312 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
23312-126674
322 if( sqlite3_stricmp(zDatabase, db->aDb[1].zDbSName)!=0 ) break;
executed 21305 times by 436 tests: break;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
sqlite3_stricm...].zDbSName)!=0Description
TRUEevaluated 21305 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 2007 times by 1 test
Evaluated by:
  • Self test (438)
2007-21305
323 zName = TEMP_MASTER_NAME;-
324 }
executed 2007 times by 1 test: end of block
Executed by:
  • Self test (438)
2007
325 return 0;
executed 147979 times by 436 tests: return 0;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
147979
326}-
327-
328/*-
329** Locate the in-memory structure that describes a particular database-
330** table given the name of that table and (optionally) the name of the-
331** database containing the table. Return NULL if not found. Also leave an-
332** error message in pParse->zErrMsg.-
333**-
334** The difference between this routine and sqlite3FindTable() is that this-
335** routine leaves an error message in pParse->zErrMsg where-
336** sqlite3FindTable() does not.-
337*/-
338Table *sqlite3LocateTable(-
339 Parse *pParse, /* context in which to report errors */-
340 u32 flags, /* LOCATE_VIEW or LOCATE_NOERR */-
341 const char *zName, /* Name of the table we are looking for */-
342 const char *zDbase /* Name of the database. Might be NULL */-
343){-
344 Table *p;-
345 sqlite3 *db = pParse->db;-
346-
347 /* Read the database schema. If an error occurs, leave an error message-
348 ** and code in pParse and return NULL. */-
349 if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0
(db->mDbFlags & 0x0008)==0Description
TRUEevaluated 54363 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1026019 times by 68 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
54363-1026019
350 && SQLITE_OK!=sqlite3ReadSchema(pParse)
0!=sqlite3ReadSchema(pParse)Description
TRUEevaluated 838 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (61)
FALSEevaluated 53525 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
838-53525
351 ){-
352 return 0;
executed 838 times by 2 tests: return 0;
Executed by:
  • Self test (438)
  • Self test (61)
838
353 }-
354-
355 p = sqlite3FindTable(db, zName, zDbase);-
356 if( p==0 ){
p==0Description
TRUEevaluated 9454 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 1070090 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
9454-1070090
357 const char *zMsg = flags & LOCATE_VIEW ? "no such view" : "no such table";
flags & 0x01Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9432 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
22-9432
358#ifndef SQLITE_OMIT_VIRTUALTABLE-
359 if( sqlite3FindDbName(db, zDbase)<1 ){
sqlite3FindDbN...(db, zDbase)<1Description
TRUEevaluated 9398 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 56 times by 2 tests
Evaluated by:
  • Self test (27)
  • Self test (438)
56-9398
360 /* If zName is the not the name of a table in the schema created using-
361 ** CREATE, then check to see if it is the name of an virtual table that-
362 ** can be an eponymous virtual table. */-
363 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);-
364 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
pMod==0Description
TRUEevaluated 9147 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 251 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3_strnic...ragma_", 7)==0Description
TRUEevaluated 8595 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 552 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
251-9147
365 pMod = sqlite3PragmaVtabRegister(db, zName);-
366 }
executed 8595 times by 1 test: end of block
Executed by:
  • Self test (438)
8595
367 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
pModDescription
TRUEevaluated 8845 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 553 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
sqlite3VtabEpo...(pParse, pMod)Description
TRUEevaluated 8845 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-8845
368 return pMod->pEpoTab;
executed 8845 times by 1 test: return pMod->pEpoTab;
Executed by:
  • Self test (438)
8845
369 }-
370 }
executed 553 times by 12 tests: end of block
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
553
371#endif-
372 if( (flags & LOCATE_NOERR)==0 ){
(flags & 0x02)==0Description
TRUEevaluated 607 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-607
373 if( zDbase ){
zDbaseDescription
TRUEevaluated 116 times by 5 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (438)
  • Self test (47)
FALSEevaluated 491 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
116-491
374 sqlite3ErrorMsg(pParse, "%s: %s.%s", zMsg, zDbase, zName);-
375 }else{
executed 116 times by 5 tests: end of block
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (438)
  • Self test (47)
116
376 sqlite3ErrorMsg(pParse, "%s: %s", zMsg, zName);-
377 }
executed 491 times by 12 tests: end of block
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
491
378 pParse->checkSchema = 1;-
379 }
executed 607 times by 12 tests: end of block
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
607
380 }
executed 609 times by 12 tests: end of block
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
609
381-
382 return p;
executed 1070699 times by 435 tests: return p;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1070699
383}-
384-
385/*-
386** Locate the table identified by *p.-
387**-
388** This is a wrapper around sqlite3LocateTable(). The difference between-
389** sqlite3LocateTable() and this function is that this function restricts-
390** the search to schema (p->pSchema) if it is not NULL. p->pSchema may be-
391** non-NULL if it is part of a view or trigger program definition. See-
392** sqlite3FixSrcList() for details.-
393*/-
394Table *sqlite3LocateTableItem(-
395 Parse *pParse, -
396 u32 flags,-
397 struct SrcList_item *p-
398){-
399 const char *zDb;-
400 assert( p->pSchema==0 || p->zDatabase==0 );-
401 if( p->pSchema ){
p->pSchemaDescription
TRUEevaluated 512810 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 555956 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
512810-555956
402 int iDb = sqlite3SchemaToIndex(pParse->db, p->pSchema);-
403 zDb = pParse->db->aDb[iDb].zDbSName;-
404 }else{
executed 512810 times by 24 tests: end of block
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
512810
405 zDb = p->zDatabase;-
406 }
executed 555956 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
555956
407 return sqlite3LocateTable(pParse, flags, p->zName, zDb);
executed 1068766 times by 436 tests: return sqlite3LocateTable(pParse, flags, p->zName, zDb);
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1068766
408}-
409-
410/*-
411** Locate the in-memory structure that describes -
412** a particular index given the name of that index-
413** and the name of the database that contains the index.-
414** Return NULL if not found.-
415**-
416** If zDatabase is 0, all databases are searched for the-
417** table and the first matching index is returned. (No checking-
418** for duplicate index names is done.) The search order is-
419** TEMP first, then MAIN, then any auxiliary databases added-
420** using the ATTACH command.-
421*/-
422Index *sqlite3FindIndex(sqlite3 *db, const char *zName, const char *zDb){-
423 Index *p = 0;-
424 int i;-
425 /* All mutexes are required for schema access. Make sure we hold them. */-
426 assert( zDb!=0 || sqlite3BtreeHoldsAllMutexes(db) );-
427 for(i=OMIT_TEMPDB; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 228990 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 100599 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
100599-228990
428 int j = (i<2) ? i^1 : i; /* Search TEMP before MAIN */
(i<2)Description
TRUEevaluated 211550 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 17440 times by 12 tests
Evaluated by:
  • Self test (27)
  • Self test (34)
  • Self test (4)
  • Self test (438)
  • Self test (5)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
17440-211550
429 Schema *pSchema = db->aDb[j].pSchema;-
430 assert( pSchema );-
431 if( zDb && sqlite3StrICmp(zDb, db->aDb[j].zDbSName) ) continue;
executed 122732 times by 436 tests: continue;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
zDbDescription
TRUEevaluated 228080 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 910 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
sqlite3StrICmp...b[j].zDbSName)Description
TRUEevaluated 122732 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 105348 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
910-228080
432 assert( sqlite3SchemaMutexHeld(db, j, 0) );-
433 p = sqlite3HashFind(&pSchema->idxHash, zName);-
434 if( p ) break;
executed 5200 times by 379 tests: break;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
pDescription
TRUEevaluated 5200 times by 379 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 101058 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
5200-101058
435 }
executed 101058 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
101058
436 return p;
executed 105799 times by 436 tests: return p;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
105799
437}-
438-
439/*-
440** Reclaim the memory used by an index-
441*/-
442void sqlite3FreeIndex(sqlite3 *db, Index *p){-
443#ifndef SQLITE_OMIT_ANALYZE-
444 sqlite3DeleteIndexSamples(db, p);-
445#endif-
446 sqlite3ExprDelete(db, p->pPartIdxWhere);-
447 sqlite3ExprListDelete(db, p->aColExpr);-
448 sqlite3DbFree(db, p->zColAff);-
449 if( p->isResized ) sqlite3DbFree(db, (void *)p->azColl);
executed 313 times by 1 test: sqlite3DbFree(db, (void *)p->azColl);
Executed by:
  • Self test (438)
p->isResizedDescription
TRUEevaluated 313 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 12681 times by 38 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • ...
313-12681
450#ifdef SQLITE_ENABLE_STAT3_OR_STAT4-
451 sqlite3_free(p->aiRowEst);-
452#endif-
453 sqlite3DbFree(db, p);-
454}
executed 12994 times by 38 tests: end of block
Executed by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • ...
12994
455-
456/*-
457** For the index called zIdxName which is found in the database iDb,-
458** unlike that index from its Table then remove the index from-
459** the index hash table and free all memory structures associated-
460** with the index.-
461*/-
462void sqlite3UnlinkAndDeleteIndex(sqlite3 *db, int iDb, const char *zIdxName){-
463 Index *pIndex;-
464 Hash *pHash;-
465-
466 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
467 pHash = &db->aDb[iDb].pSchema->idxHash;-
468 pIndex = sqlite3HashInsert(pHash, zIdxName, 0);-
469 if( ALWAYS(pIndex) ){
(pIndex)Description
TRUEevaluated 199 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEnever evaluated
0-199
470 if( pIndex->pTable->pIndex==pIndex ){
pIndex->pTable->pIndex==pIndexDescription
TRUEevaluated 179 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
20-179
471 pIndex->pTable->pIndex = pIndex->pNext;-
472 }else{
executed 179 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
179
473 Index *p;-
474 /* Justification of ALWAYS(); The index must be on the list of-
475 ** indices. */-
476 p = pIndex->pTable->pIndex;-
477 while( ALWAYS(p) && p->pNext!=pIndex ){ p = p->pNext; }
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
(p)Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
p->pNext!=pIndexDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
0-21
478 if( ALWAYS(p && p->pNext==pIndex) ){
pDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
p->pNext==pIndexDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-20
479 p->pNext = pIndex->pNext;-
480 }
executed 20 times by 1 test: end of block
Executed by:
  • Self test (438)
20
481 }
executed 20 times by 1 test: end of block
Executed by:
  • Self test (438)
20
482 sqlite3FreeIndex(db, pIndex);-
483 }
executed 199 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
199
484 db->mDbFlags |= DBFLAG_SchemaChange;-
485}
executed 199 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
199
486-
487/*-
488** Look through the list of open database files in db->aDb[] and if-
489** any have been closed, remove them from the list. Reallocate the-
490** db->aDb[] structure to a smaller size, if possible.-
491**-
492** Entry 0 (the "main" database) and entry 1 (the "temp" database)-
493** are never candidates for being collapsed.-
494*/-
495void sqlite3CollapseDatabaseArray(sqlite3 *db){-
496 int i, j;-
497 for(i=j=2; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 2105 times by 10 tests
Evaluated by:
  • Self test (27)
  • Self test (34)
  • Self test (438)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 34431 times by 66 tests
Evaluated by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
2105-34431
498 struct Db *pDb = &db->aDb[i];-
499 if( pDb->pBt==0 ){
pDb->pBt==0Description
TRUEevaluated 1631 times by 10 tests
Evaluated by:
  • Self test (27)
  • Self test (34)
  • Self test (438)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 474 times by 1 test
Evaluated by:
  • Self test (438)
474-1631
500 sqlite3DbFree(db, pDb->zDbSName);-
501 pDb->zDbSName = 0;-
502 continue;
executed 1631 times by 10 tests: continue;
Executed by:
  • Self test (27)
  • Self test (34)
  • Self test (438)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1631
503 }-
504 if( j<i ){
j<iDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 449 times by 1 test
Evaluated by:
  • Self test (438)
25-449
505 db->aDb[j] = db->aDb[i];-
506 }
executed 25 times by 1 test: end of block
Executed by:
  • Self test (438)
25
507 j++;-
508 }
executed 474 times by 1 test: end of block
Executed by:
  • Self test (438)
474
509 db->nDb = j;-
510 if( db->nDb<=2 && db->aDb!=db->aDbStatic ){
db->nDb<=2Description
TRUEevaluated 34013 times by 66 tests
Evaluated by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
FALSEevaluated 418 times by 1 test
Evaluated by:
  • Self test (438)
db->aDb!=db->aDbStaticDescription
TRUEevaluated 1535 times by 10 tests
Evaluated by:
  • Self test (27)
  • Self test (34)
  • Self test (438)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 32478 times by 58 tests
Evaluated by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • ...
418-34013
511 memcpy(db->aDbStatic, db->aDb, 2*sizeof(db->aDb[0]));-
512 sqlite3DbFree(db, db->aDb);-
513 db->aDb = db->aDbStatic;-
514 }
executed 1535 times by 10 tests: end of block
Executed by:
  • Self test (27)
  • Self test (34)
  • Self test (438)
  • Self test (77)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1535
515}
executed 34431 times by 66 tests: end of block
Executed by:
  • Self test (101)
  • Self test (102)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (25)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
34431
516-
517/*-
518** Reset the schema for the database at index iDb. Also reset the-
519** TEMP schema. The reset is deferred if db->nSchemaLock is not zero.-
520** Deferred resets may be run by calling with iDb<0.-
521*/-
522void sqlite3ResetOneSchema(sqlite3 *db, int iDb){-
523 int i;-
524 assert( iDb<db->nDb );-
525-
526 if( iDb>=0 ){
iDb>=0Description
TRUEevaluated 1324 times by 18 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 152 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
152-1324
527 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
528 DbSetProperty(db, iDb, DB_ResetWanted);-
529 DbSetProperty(db, 1, DB_ResetWanted);-
530 db->mDbFlags &= ~DBFLAG_SchemaKnownOk;-
531 }
executed 1324 times by 18 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1324
532-
533 if( db->nSchemaLock==0 ){
db->nSchemaLock==0Description
TRUEevaluated 1476 times by 18 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEnever evaluated
0-1476
534 for(i=0; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 3170 times by 18 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 1476 times by 18 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1476-3170
535 if( DbHasProperty(db, i, DB_ResetWanted) ){
(((db)->aDb[i]...8))==(0x0008))Description
TRUEevaluated 2525 times by 18 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
FALSEevaluated 645 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
645-2525
536 sqlite3SchemaClear(db->aDb[i].pSchema);-
537 }
executed 2525 times by 18 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
2525
538 }
executed 3170 times by 18 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
3170
539 }
executed 1476 times by 18 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1476
540}
executed 1476 times by 18 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (61)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
1476
541-
542/*-
543** Erase all schema information from all attached databases (including-
544** "main" and "temp") for a single database connection.-
545*/-
546void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){-
547 int i;-
548 sqlite3BtreeEnterAll(db);-
549 assert( db->nSchemaLock==0 );-
550 for(i=0; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 5525 times by 3 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
  • Self test (61)
FALSEevaluated 2125 times by 3 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
  • Self test (61)
2125-5525
551 Db *pDb = &db->aDb[i];-
552 if( pDb->pSchema ){
pDb->pSchemaDescription
TRUEevaluated 4648 times by 3 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
  • Self test (61)
FALSEevaluated 877 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
877-4648
553 sqlite3SchemaClear(pDb->pSchema);-
554 }
executed 4648 times by 3 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
  • Self test (61)
4648
555 }
executed 5525 times by 3 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
  • Self test (61)
5525
556 db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);-
557 sqlite3VtabUnlockList(db);-
558 sqlite3BtreeLeaveAll(db);-
559 sqlite3CollapseDatabaseArray(db);-
560}
executed 2125 times by 3 tests: end of block
Executed by:
  • Self test (34)
  • Self test (438)
  • Self test (61)
2125
561-
562/*-
563** This routine is called when a commit occurs.-
564*/-
565void sqlite3CommitInternalChanges(sqlite3 *db){-
566 db->mDbFlags &= ~DBFLAG_SchemaChange;-
567}
executed 415167 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
415167
568-
569/*-
570** Delete memory allocated for the column names of a table or view (the-
571** Table.aCol[] array).-
572*/-
573void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){-
574 int i;-
575 Column *pCol;-
576 assert( pTable!=0 );-
577 if( (pCol = pTable->aCol)!=0 ){
(pCol = pTable->aCol)!=0Description
TRUEevaluated 101299 times by 77 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
FALSEevaluated 16488 times by 10 tests
Evaluated by:
  • Self test
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
  • Self test (57)
  • Self test (58)
16488-101299
578 for(i=0; i<pTable->nCol; i++, pCol++){
i<pTable->nColDescription
TRUEevaluated 445232 times by 77 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
FALSEevaluated 101299 times by 77 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
101299-445232
579 sqlite3DbFree(db, pCol->zName);-
580 sqlite3ExprDelete(db, pCol->pDflt);-
581 sqlite3DbFree(db, pCol->zColl);-
582 }
executed 445232 times by 77 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
445232
583 sqlite3DbFree(db, pTable->aCol);-
584 }
executed 101299 times by 77 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
101299
585}
executed 117787 times by 77 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
117787
586-
587/*-
588** Remove the memory data structures associated with the given-
589** Table. No changes are made to disk by this routine.-
590**-
591** This routine just deletes the data structure. It does not unlink-
592** the table data structure from the hash table. But it does destroy-
593** memory structures of the indices and foreign keys associated with -
594** the table.-
595**-
596** The db parameter is optional. It is needed if the Table object -
597** contains lookaside memory. (Table objects in the schema do not use-
598** lookaside memory, but some ephemeral Table objects do.) Or the-
599** db parameter can be used with db->pnBytesFreed to measure the memory-
600** used by the Table object.-
601*/-
602static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){-
603 Index *pIndex, *pNext;-
604-
605#ifdef SQLITE_DEBUG-
606 /* Record the number of outstanding lookaside allocations in schema Tables-
607 ** prior to doing any free() operations. Since schema Tables do not use-
608 ** lookaside, this number should not change. */-
609 int nLookaside = 0;-
610 if( db && (pTable->tabFlags & TF_Ephemeral)==0 ){-
611 nLookaside = sqlite3LookasideUsed(db, 0);-
612 }-
613#endif-
614-
615 /* Delete all indices associated with this table. */-
616 for(pIndex = pTable->pIndex; pIndex; pIndex=pNext){
pIndexDescription
TRUEevaluated 10174 times by 38 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • ...
FALSEevaluated 117647 times by 77 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
10174-117647
617 pNext = pIndex->pNext;-
618 assert( pIndex->pSchema==pTable->pSchema-
619 || (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );-
620 if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){
db==0Description
TRUEevaluated 7482 times by 28 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
  • ...
FALSEevaluated 2692 times by 13 tests
Evaluated by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
db->pnBytesFreed==0Description
TRUEevaluated 2692 times by 13 tests
Evaluated by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEnever evaluated
!((pTable)->nModuleArg)Description
TRUEevaluated 10135 times by 38 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • ...
FALSEevaluated 39 times by 1 test
Evaluated by:
  • Self test (438)
0-10135
621 char *zName = pIndex->zName; -
622 TESTONLY ( Index *pOld = ) sqlite3HashInsert(-
623 &pIndex->pSchema->idxHash, zName, 0-
624 );-
625 assert( db==0 || sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );-
626 assert( pOld==pIndex || pOld==0 );-
627 }
executed 10135 times by 38 tests: end of block
Executed by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • ...
10135
628 sqlite3FreeIndex(db, pIndex);-
629 }
executed 10174 times by 38 tests: end of block
Executed by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • ...
10174
630-
631 /* Delete any foreign keys attached to this table. */-
632 sqlite3FkDelete(db, pTable);-
633-
634 /* Delete the Table structure itself.-
635 */-
636 sqlite3DeleteColumnNames(db, pTable);-
637 sqlite3DbFree(db, pTable->zName);-
638 sqlite3DbFree(db, pTable->zColAff);-
639 sqlite3SelectDelete(db, pTable->pSelect);-
640 sqlite3ExprListDelete(db, pTable->pCheck);-
641#ifndef SQLITE_OMIT_VIRTUALTABLE-
642 sqlite3VtabClear(db, pTable);-
643#endif-
644 sqlite3DbFree(db, pTable);-
645-
646 /* Verify that no lookaside memory was used by schema tables */-
647 assert( nLookaside==0 || nLookaside==sqlite3LookasideUsed(db,0) );-
648}
executed 117647 times by 77 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
117647
649void sqlite3DeleteTable(sqlite3 *db, Table *pTable){-
650 /* Do not delete the table until the reference count reaches zero. */-
651 if( !pTable ) return;
executed 713213 times by 436 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
!pTableDescription
TRUEevaluated 713213 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1140874 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
713213-1140874
652 if( ((!db || db->pnBytesFreed==0) && (--pTable->nTabRef)>0) ) return;
executed 1023227 times by 435 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
!dbDescription
TRUEevaluated 74468 times by 64 tests
Evaluated by:
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • ...
FALSEevaluated 1066406 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
db->pnBytesFreed==0Description
TRUEevaluated 1066406 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEnever evaluated
(--pTable->nTabRef)>0Description
TRUEevaluated 1023227 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 117647 times by 77 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
0-1066406
653 deleteTable(db, pTable);-
654}
executed 117647 times by 77 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (31)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (35)
  • Self test (36)
  • Self test (37)
  • Self test (38)
  • Self test (39)
  • Self test (40)
  • Self test (41)
  • Self test (42)
  • Self test (43)
  • ...
117647
655-
656-
657/*-
658** Unlink the given table from the hash tables and the delete the-
659** table structure with all its indices and foreign keys.-
660*/-
661void sqlite3UnlinkAndDeleteTable(sqlite3 *db, int iDb, const char *zTabName){-
662 Table *p;-
663 Db *pDb;-
664-
665 assert( db!=0 );-
666 assert( iDb>=0 && iDb<db->nDb );-
667 assert( zTabName );-
668 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
669 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */-
670 pDb = &db->aDb[iDb];-
671 p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, 0);-
672 sqlite3DeleteTable(db, p);-
673 db->mDbFlags |= DBFLAG_SchemaChange;-
674}
executed 4808 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4808
675-
676/*-
677** Given a token, return a string that consists of the text of that-
678** token. Space to hold the returned string-
679** is obtained from sqliteMalloc() and must be freed by the calling-
680** function.-
681**-
682** Any quotation marks (ex: "name", 'name', [name], or `name`) that-
683** surround the body of the token are removed.-
684**-
685** Tokens are often just pointers into the original SQL text and so-
686** are not \000 terminated and are not persistent. The returned string-
687** is \000 terminated and is persistent.-
688*/-
689char *sqlite3NameFromToken(sqlite3 *db, Token *pName){-
690 char *zName;-
691 if( pName ){
pNameDescription
TRUEevaluated 857781 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 23940 times by 21 tests
Evaluated by:
  • Self test (101)
  • Self test (104)
  • Self test (35)
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (72)
  • Self test (73)
  • Self test (74)
  • Self test (84)
  • Self test (85)
  • Self test (89)
  • Self test (90)
23940-857781
692 zName = sqlite3DbStrNDup(db, (char*)pName->z, pName->n);-
693 sqlite3Dequote(zName);-
694 }else{
executed 857781 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
857781
695 zName = 0;-
696 }
executed 23940 times by 21 tests: end of block
Executed by:
  • Self test (101)
  • Self test (104)
  • Self test (35)
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (72)
  • Self test (73)
  • Self test (74)
  • Self test (84)
  • Self test (85)
  • Self test (89)
  • Self test (90)
23940
697 return zName;
executed 881721 times by 436 tests: return zName;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
881721
698}-
699-
700/*-
701** Open the sqlite_master table stored in database number iDb for-
702** writing. The table is opened using cursor 0.-
703*/-
704void sqlite3OpenMasterTable(Parse *p, int iDb){-
705 Vdbe *v = sqlite3GetVdbe(p);-
706 sqlite3TableLock(p, iDb, MASTER_ROOT, 1, MASTER_NAME);-
707 sqlite3VdbeAddOp4Int(v, OP_OpenWrite, 0, MASTER_ROOT, iDb, 5);-
708 if( p->nTab==0 ){
p->nTab==0Description
TRUEevaluated 23567 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
FALSEevaluated 106 times by 1 test
Evaluated by:
  • Self test (438)
106-23567
709 p->nTab = 1;-
710 }
executed 23567 times by 30 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
23567
711}
executed 23673 times by 30 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
23673
712-
713/*-
714** Parameter zName points to a nul-terminated buffer containing the name-
715** of a database ("main", "temp" or the name of an attached db). This-
716** function returns the index of the named database in db->aDb[], or-
717** -1 if the named db cannot be found.-
718*/-
719int sqlite3FindDbName(sqlite3 *db, const char *zName){-
720 int i = -1; /* Database number */-
721 if( zName ){
zNameDescription
TRUEevaluated 7295 times by 16 tests
Evaluated by:
  • Self test (100)
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 9338 times by 12 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
7295-9338
722 Db *pDb;-
723 for(i=(db->nDb-1), pDb=&db->aDb[i]; i>=0; i--, pDb--){
i>=0Description
TRUEevaluated 14083 times by 16 tests
Evaluated by:
  • Self test (100)
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 104 times by 1 test
Evaluated by:
  • Self test (438)
104-14083
724 if( 0==sqlite3_stricmp(pDb->zDbSName, zName) ) break;
executed 7182 times by 16 tests: break;
Executed by:
  • Self test (100)
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
0==sqlite3_str...bSName, zName)Description
TRUEevaluated 7182 times by 16 tests
Evaluated by:
  • Self test (100)
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 6901 times by 15 tests
Evaluated by:
  • Self test (100)
  • Self test (26)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
6901-7182
725 /* "main" is always an acceptable alias for the primary database-
726 ** even if it has been renamed using SQLITE_DBCONFIG_MAINDBNAME. */-
727 if( i==0 && 0==sqlite3_stricmp("main", zName) ) break;
executed 9 times by 1 test: break;
Executed by:
  • Self test (438)
i==0Description
TRUEevaluated 113 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6788 times by 15 tests
Evaluated by:
  • Self test (100)
  • Self test (26)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
0==sqlite3_str..."main", zName)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 104 times by 1 test
Evaluated by:
  • Self test (438)
9-6788
728 }
executed 6892 times by 15 tests: end of block
Executed by:
  • Self test (100)
  • Self test (26)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
6892
729 }
executed 7295 times by 16 tests: end of block
Executed by:
  • Self test (100)
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (34)
  • Self test (438)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
7295
730 return i;
executed 16633 times by 23 tests: return i;
Executed by:
  • Self test (100)
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (78)
  • Self test (79)
  • Self test (80)
  • Self test (81)
  • Self test (82)
  • Self test (83)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
16633
731}-
732-
733/*-
734** The token *pName contains the name of a database (either "main" or-
735** "temp" or the name of an attached db). This routine returns the-
736** index of the named database in db->aDb[], or -1 if the named db -
737** does not exist.-
738*/-
739int sqlite3FindDb(sqlite3 *db, Token *pName){-
740 int i; /* Database number */-
741 char *zName; /* Name we are searching for */-
742 zName = sqlite3NameFromToken(db, pName);-
743 i = sqlite3FindDbName(db, zName);-
744 sqlite3DbFree(db, zName);-
745 return i;
executed 2397 times by 12 tests: return i;
Executed by:
  • Self test (100)
  • Self test (27)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
2397
746}-
747-
748/* The table or view or trigger name is passed to this routine via tokens-
749** pName1 and pName2. If the table name was fully qualified, for example:-
750**-
751** CREATE TABLE xxx.yyy (...);-
752** -
753** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if-
754** the table name is not fully qualified, i.e.:-
755**-
756** CREATE TABLE yyy(...);-
757**-
758** Then pName1 is set to "yyy" and pName2 is "".-
759**-
760** This routine sets the *ppUnqual pointer to point at the token (pName1 or-
761** pName2) that stores the unqualified table name. The index of the-
762** database "xxx" is returned.-
763*/-
764int sqlite3TwoPartName(-
765 Parse *pParse, /* Parsing and code generating context */-
766 Token *pName1, /* The "xxx" in the name "xxx.yyy" or "xxx" */-
767 Token *pName2, /* The "yyy" in the name "xxx.yyy" */-
768 Token **pUnqual /* Write the unqualified object name here */-
769){-
770 int iDb; /* Database holding the object */-
771 sqlite3 *db = pParse->db;-
772-
773 assert( pName2!=0 );-
774 if( pName2->n>0 ){
pName2->n>0Description
TRUEevaluated 2317 times by 12 tests
Evaluated by:
  • Self test (100)
  • Self test (27)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 117992 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
2317-117992
775 if( db->init.busy ) {
db->init.busyDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2315 times by 12 tests
Evaluated by:
  • Self test (100)
  • Self test (27)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
2-2315
776 sqlite3ErrorMsg(pParse, "corrupt database");-
777 return -1;
executed 2 times by 1 test: return -1;
Executed by:
  • Self test (438)
2
778 }-
779 *pUnqual = pName2;-
780 iDb = sqlite3FindDb(db, pName1);-
781 if( iDb<0 ){
iDb<0Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2303 times by 12 tests
Evaluated by:
  • Self test (100)
  • Self test (27)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
12-2303
782 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);-
783 return -1;
executed 12 times by 1 test: return -1;
Executed by:
  • Self test (438)
12
784 }-
785 }else{
executed 2303 times by 12 tests: end of block
Executed by:
  • Self test (100)
  • Self test (27)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
2303
786 assert( db->init.iDb==0 || db->init.busy || IN_RENAME_OBJECT-
787 || (db->mDbFlags & DBFLAG_Vacuum)!=0);-
788 iDb = db->init.iDb;-
789 *pUnqual = pName1;-
790 }
executed 117992 times by 434 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
117992
791 return iDb;
executed 120295 times by 434 tests: return iDb;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
120295
792}-
793-
794/*-
795** This routine is used to check if the UTF-8 string zName is a legal-
796** unqualified name for a new schema object (table, index, view or-
797** trigger). All names are legal except those that begin with the string-
798** "sqlite_" (in upper, lower or mixed case). This portion of the namespace-
799** is reserved for internal use.-
800*/-
801int sqlite3CheckObjectName(Parse *pParse, const char *zName){-
802 if( !pParse->db->init.busy && pParse->nested==0
!pParse->db->init.busyDescription
TRUEevaluated 27868 times by 33 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
FALSEevaluated 92734 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pParse->nested==0Description
TRUEevaluated 27762 times by 33 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
FALSEevaluated 106 times by 1 test
Evaluated by:
  • Self test (438)
106-92734
803 && (pParse->db->flags & SQLITE_WriteSchema)==0
(pParse->db->f...0x00000001)==0Description
TRUEevaluated 25599 times by 32 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • ...
FALSEevaluated 2163 times by 2 tests
Evaluated by:
  • Self test (34)
  • Self test (438)
2163-25599
804 && 0==sqlite3StrNICmp(zName, "sqlite_", 7) ){
0==sqlite3_str... "sqlite_", 7)Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 25585 times by 32 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • ...
14-25585
805 sqlite3ErrorMsg(pParse, "object name reserved for internal use: %s", zName);-
806 return SQLITE_ERROR;
executed 14 times by 1 test: return 1;
Executed by:
  • Self test (438)
14
807 }-
808 return SQLITE_OK;
executed 120588 times by 436 tests: return 0;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
120588
809}-
810-
811/*-
812** Return the PRIMARY KEY index of a table-
813*/-
814Index *sqlite3PrimaryKeyIndex(Table *pTab){-
815 Index *p;-
816 for(p=pTab->pIndex; p && !IsPrimaryKeyIndex(p); p=p->pNext){}
executed 3334 times by 1 test: end of block
Executed by:
  • Self test (438)
pDescription
TRUEevaluated 12836 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8688 times by 1 test
Evaluated by:
  • Self test (438)
!((p)->idxType==2)Description
TRUEevaluated 3334 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 9502 times by 1 test
Evaluated by:
  • Self test (438)
3334-12836
817 return p;
executed 18190 times by 1 test: return p;
Executed by:
  • Self test (438)
18190
818}-
819-
820/*-
821** Return the column of index pIdx that corresponds to table-
822** column iCol. Return -1 if not found.-
823*/-
824i16 sqlite3ColumnOfIndex(Index *pIdx, i16 iCol){-
825 int i;-
826 for(i=0; i<pIdx->nColumn; i++){
i<pIdx->nColumnDescription
TRUEevaluated 1207072 times by 21 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 37197 times by 6 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (47)
37197-1207072
827 if( iCol==pIdx->aiColumn[i] ) return i;
executed 46096 times by 19 tests: return i;
Executed by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
iCol==pIdx->aiColumn[i]Description
TRUEevaluated 46096 times by 19 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 1160976 times by 12 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (28)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (86)
  • Self test (87)
  • Self test (88)
46096-1160976
828 }
executed 1160976 times by 12 tests: end of block
Executed by:
  • Self test (2)
  • Self test (24)
  • Self test (28)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (47)
  • Self test (53)
  • Self test (86)
  • Self test (87)
  • Self test (88)
1160976
829 return -1;
executed 37197 times by 6 tests: return -1;
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (47)
37197
830}-
831-
832/*-
833** Begin constructing a new table representation in memory. This is-
834** the first of several action routines that get called in response-
835** to a CREATE TABLE statement. In particular, this routine is called-
836** after seeing tokens "CREATE" and "TABLE" and the table name. The isTemp-
837** flag is true if the table should be stored in the auxiliary database-
838** file instead of in the main database file. This is normally the case-
839** when the "TEMP" or "TEMPORARY" keyword occurs in between-
840** CREATE and TABLE.-
841**-
842** The new table record is initialized and put in pParse->pNewTable.-
843** As more of the CREATE TABLE statement is parsed, additional action-
844** routines will be called to add more information to this record.-
845** At the end of the CREATE TABLE statement, the sqlite3EndTable() routine-
846** is called to complete the construction of the new table record.-
847*/-
848void sqlite3StartTable(-
849 Parse *pParse, /* Parser context */-
850 Token *pName1, /* First part of the name of the table or view */-
851 Token *pName2, /* Second part of the name of the table or view */-
852 int isTemp, /* True if this is a TEMP table */-
853 int isView, /* True if this is a VIEW */-
854 int isVirtual, /* True if this is a VIRTUAL table */-
855 int noErr /* Do nothing if table already exists */-
856){-
857 Table *pTable;-
858 char *zName = 0; /* The name of the new table */-
859 sqlite3 *db = pParse->db;-
860 Vdbe *v;-
861 int iDb; /* Database number to create the table in */-
862 Token *pName; /* Unqualified name of the table to create */-
863-
864 if( db->init.busy && db->init.newTnum==1 ){
db->init.busyDescription
TRUEevaluated 80703 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 23760 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
db->init.newTnum==1Description
TRUEevaluated 40580 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 40123 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
23760-80703
865 /* Special case: Parsing the sqlite_master or sqlite_temp_master schema */-
866 iDb = db->init.iDb;-
867 zName = sqlite3DbStrDup(db, SCHEMA_TABLE(iDb));-
868 pName = pName1;-
869 }else{
executed 40580 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
40580
870 /* The common case */-
871 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);-
872 if( iDb<0 ) return;
executed 5 times by 1 test: return;
Executed by:
  • Self test (438)
iDb<0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 63878 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
5-63878
873 if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){
isTempDescription
TRUEevaluated 321 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 63557 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pName2->n>0Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 308 times by 1 test
Evaluated by:
  • Self test (438)
iDb!=1Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
5-63557
874 /* If creating a temp table, the name may not be qualified. Unless -
875 ** the database name is "temp" anyway. */-
876 sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");-
877 return;
executed 5 times by 1 test: return;
Executed by:
  • Self test (438)
5
878 }-
879 if( !OMIT_TEMPDB && isTemp ) iDb = 1;
executed 316 times by 1 test: iDb = 1;
Executed by:
  • Self test (438)
isTempDescription
TRUEevaluated 316 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 63557 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
316-63557
880 zName = sqlite3NameFromToken(db, pName);-
881 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 905 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 62968 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
905-62968
882 sqlite3RenameTokenMap(pParse, (void*)zName, pName);-
883 }
executed 905 times by 1 test: end of block
Executed by:
  • Self test (438)
905
884 }
executed 63873 times by 434 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
63873
885 pParse->sNameToken = *pName;-
886 if( zName==0 ) return;
executed 29 times by 1 test: return;
Executed by:
  • Self test (438)
zName==0Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 104424 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
29-104424
887 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
0!=sqlite3Chec...pParse, zName)Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 104413 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
11-104413
888 goto begin_table_error;
executed 11 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
11
889 }-
890 if( db->init.iDb==1 ) isTemp = 1;
executed 20259 times by 435 tests: isTemp = 1;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
db->init.iDb==1Description
TRUEevaluated 20259 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 84154 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
20259-84154
891#ifndef SQLITE_OMIT_AUTHORIZATION-
892 assert( isTemp==0 || isTemp==1 );-
893 assert( isView==0 || isView==1 );-
894 {-
895 static const u8 aCode[] = {-
896 SQLITE_CREATE_TABLE,-
897 SQLITE_CREATE_TEMP_TABLE,-
898 SQLITE_CREATE_VIEW,-
899 SQLITE_CREATE_TEMP_VIEW-
900 };-
901 char *zDb = db->aDb[iDb].zDbSName;-
902 if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(isTemp), 0, zDb) ){
sqlite3AuthChe...ter"), 0, zDb)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 104404 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
9-104404
903 goto begin_table_error;
executed 9 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
9
904 }-
905 if( !isVirtual && sqlite3AuthCheck(pParse, (int)aCode[isTemp+2*isView],
!isVirtualDescription
TRUEevaluated 102181 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 2223 times by 1 test
Evaluated by:
  • Self test (438)
sqlite3AuthChe...zName, 0, zDb)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 102173 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
8-102181
906 zName, 0, zDb) ){
sqlite3AuthChe...zName, 0, zDb)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 102173 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
8-102173
907 goto begin_table_error;
executed 8 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
8
908 }-
909 }-
910#endif-
911-
912 /* Make sure the new table name does not collide with an existing-
913 ** index or table name in the same database. Issue an error message if-
914 ** it does. The exception is if the statement being parsed was passed-
915 ** to an sqlite3_declare_vtab() call. In that case only the column names-
916 ** and types will be used, so there is no need to test for namespace-
917 ** collisions.-
918 */-
919 if( !IN_SPECIAL_PARSE ){
!(pParse->eParseMode!=0)Description
TRUEevaluated 93875 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 10521 times by 1 test
Evaluated by:
  • Self test (438)
10521-93875
920 char *zDb = db->aDb[iDb].zDbSName;-
921 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
0!=sqlite3ReadSchema(pParse)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 93872 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
3-93872
922 goto begin_table_error;
executed 3 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
3
923 }-
924 pTable = sqlite3FindTable(db, zName, zDb);-
925 if( pTable ){
pTableDescription
TRUEevaluated 43 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 93829 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
43-93829
926 if( !noErr ){
!noErrDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test (438)
19-24
927 sqlite3ErrorMsg(pParse, "table %T already exists", pName);-
928 }else{
executed 19 times by 1 test: end of block
Executed by:
  • Self test (438)
19
929 assert( !db->init.busy || CORRUPT_DB );-
930 sqlite3CodeVerifySchema(pParse, iDb);-
931 }
executed 24 times by 1 test: end of block
Executed by:
  • Self test (438)
24
932 goto begin_table_error;
executed 43 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
43
933 }-
934 if( sqlite3FindIndex(db, zName, zDb)!=0 ){
sqlite3FindInd...zName, zDb)!=0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 93823 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
6-93823
935 sqlite3ErrorMsg(pParse, "there is already an index named %s", zName);-
936 goto begin_table_error;
executed 6 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
6
937 }-
938 }
executed 93823 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
93823
939-
940 pTable = sqlite3DbMallocZero(db, sizeof(Table));-
941 if( pTable==0 ){
pTable==0Description
TRUEevaluated 26 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 104318 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
26-104318
942 assert( db->mallocFailed );-
943 pParse->rc = SQLITE_NOMEM_BKPT;-
944 pParse->nErr++;-
945 goto begin_table_error;
executed 26 times by 1 test: goto begin_table_error;
Executed by:
  • Self test (438)
26
946 }-
947 pTable->zName = zName;-
948 pTable->iPKey = -1;-
949 pTable->pSchema = db->aDb[iDb].pSchema;-
950 pTable->nTabRef = 1;-
951#ifdef SQLITE_DEFAULT_ROWEST-
952 pTable->nRowLogEst = sqlite3LogEst(SQLITE_DEFAULT_ROWEST);-
953#else-
954 pTable->nRowLogEst = 200; assert( 200==sqlite3LogEst(1048576) );-
955#endif-
956 assert( pParse->pNewTable==0 );-
957 pParse->pNewTable = pTable;-
958-
959 /* If this is the magic sqlite_sequence table used by autoincrement,-
960 ** then record a pointer to this table in the main database structure-
961 ** so that INSERT can find the table easily.-
962 */-
963#ifndef SQLITE_OMIT_AUTOINCREMENT-
964 if( !pParse->nested && strcmp(zName, "sqlite_sequence")==0 ){
never executed: __result = (((const unsigned char *) (const char *) ( zName ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( "sqlite_sequence" ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
!pParse->nestedDescription
TRUEevaluated 104212 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 106 times by 1 test
Evaluated by:
  • Self test (438)
__extension__ ..." )))); }) ==0Description
TRUEevaluated 91 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 104121 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0-104212
965 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
966 pTable->pSchema->pSeqTab = pTable;-
967 }
executed 91 times by 1 test: end of block
Executed by:
  • Self test (438)
91
968#endif-
969-
970 /* Begin generating the code that will insert the table record into-
971 ** the SQLITE_MASTER table. Note in particular that we must go ahead-
972 ** and allocate the record number for the table entry now. Before any-
973 ** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause-
974 ** indices to be created and the table record must come before the -
975 ** indices. Hence, the record number for the table must be allocated-
976 ** now.-
977 */-
978 if( !db->init.busy && (v = sqlite3GetVdbe(pParse))!=0 ){
!db->init.busyDescription
TRUEevaluated 23673 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
FALSEevaluated 80645 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
(v = sqlite3Ge...be(pParse))!=0Description
TRUEevaluated 23673 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
FALSEnever evaluated
0-80645
979 int addr1;-
980 int fileFormat;-
981 int reg1, reg2, reg3;-
982 /* nullRow[] is an OP_Record encoding of a row containing 5 NULLs */-
983 static const char nullRow[] = { 6, 0, 0, 0, 0, 0 };-
984 sqlite3BeginWriteOperation(pParse, 1, iDb);-
985-
986#ifndef SQLITE_OMIT_VIRTUALTABLE-
987 if( isVirtual ){
isVirtualDescription
TRUEevaluated 1027 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 22646 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
1027-22646
988 sqlite3VdbeAddOp0(v, OP_VBegin);-
989 }
executed 1027 times by 1 test: end of block
Executed by:
  • Self test (438)
1027
990#endif-
991-
992 /* If the file format and encoding in the database have not been set, -
993 ** set them now.-
994 */-
995 reg1 = pParse->regRowid = ++pParse->nMem;-
996 reg2 = pParse->regRoot = ++pParse->nMem;-
997 reg3 = ++pParse->nMem;-
998 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, reg3, BTREE_FILE_FORMAT);-
999 sqlite3VdbeUsesBtree(v, iDb);-
1000 addr1 = sqlite3VdbeAddOp1(v, OP_If, reg3); VdbeCoverage(v);-
1001 fileFormat = (db->flags & SQLITE_LegacyFileFmt)!=0 ?
(db->flags & 0x00000002)!=0Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 23649 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
24-23649
1002 1 : SQLITE_MAX_FILE_FORMAT;-
1003 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, fileFormat);-
1004 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_TEXT_ENCODING, ENC(db));-
1005 sqlite3VdbeJumpHere(v, addr1);-
1006-
1007 /* This just creates a place-holder record in the sqlite_master table.-
1008 ** The record created does not contain anything yet. It will be replaced-
1009 ** by the real entry in code generated at sqlite3EndTable().-
1010 **-
1011 ** The rowid for the new entry is left in register pParse->regRowid.-
1012 ** The root page number of the new table is left in reg pParse->regRoot.-
1013 ** The rowid and root page number values are needed by the code that-
1014 ** sqlite3EndTable will generate.-
1015 */-
1016#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)-
1017 if( isView || isVirtual ){
isViewDescription
TRUEevaluated 558 times by 6 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
FALSEevaluated 23115 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
isVirtualDescription
TRUEevaluated 1027 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 22088 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
558-23115
1018 sqlite3VdbeAddOp2(v, OP_Integer, 0, reg2);-
1019 }else
executed 1585 times by 6 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
1585
1020#endif-
1021 {-
1022 pParse->addrCrTab =-
1023 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, reg2, BTREE_INTKEY);-
1024 }
executed 22088 times by 30 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
22088
1025 sqlite3OpenMasterTable(pParse, iDb);-
1026 sqlite3VdbeAddOp2(v, OP_NewRowid, 0, reg1);-
1027 sqlite3VdbeAddOp4(v, OP_Blob, 6, reg3, 0, nullRow, P4_STATIC);-
1028 sqlite3VdbeAddOp3(v, OP_Insert, 0, reg3, reg1);-
1029 sqlite3VdbeChangeP5(v, OPFLAG_APPEND);-
1030 sqlite3VdbeAddOp0(v, OP_Close);-
1031 }
executed 23673 times by 30 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
23673
1032-
1033 /* Normal (non-error) return. */-
1034 return;
executed 104318 times by 436 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
104318
1035-
1036 /* If an error occurs, we jump here */-
1037begin_table_error:-
1038 sqlite3DbFree(db, zName);-
1039 return;
executed 106 times by 1 test: return;
Executed by:
  • Self test (438)
106
1040}-
1041-
1042/* Set properties of a table column based on the (magical)-
1043** name of the column.-
1044*/-
1045#if SQLITE_ENABLE_HIDDEN_COLUMNS-
1046void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){-
1047 if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){-
1048 pCol->colFlags |= COLFLAG_HIDDEN;-
1049 }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){-
1050 pTab->tabFlags |= TF_OOOHidden;-
1051 }-
1052}-
1053#endif-
1054-
1055-
1056/*-
1057** Add a new column to the table currently being constructed.-
1058**-
1059** The parser calls this routine once for each column declaration-
1060** in a CREATE TABLE statement. sqlite3StartTable() gets called-
1061** first to get things going. Then this routine is called for each-
1062** column.-
1063*/-
1064void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){-
1065 Table *p;-
1066 int i;-
1067 char *z;-
1068 char *zType;-
1069 Column *pCol;-
1070 sqlite3 *db = pParse->db;-
1071 if( (p = pParse->pNewTable)==0 ) return;
executed 38 times by 1 test: return;
Executed by:
  • Self test (438)
(p = pParse->pNewTable)==0Description
TRUEevaluated 38 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 421502 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
38-421502
1072 if( p->nCol+1>db->aLimit[SQLITE_LIMIT_COLUMN] ){
p->nCol+1>db->aLimit[2]Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 421499 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
3-421499
1073 sqlite3ErrorMsg(pParse, "too many columns on %s", p->zName);-
1074 return;
executed 3 times by 1 test: return;
Executed by:
  • Self test (438)
3
1075 }-
1076 z = sqlite3DbMallocRaw(db, pName->n + pType->n + 2);-
1077 if( z==0 ) return;
executed 118 times by 1 test: return;
Executed by:
  • Self test (438)
z==0Description
TRUEevaluated 118 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 421381 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
118-421381
1078 if( IN_RENAME_OBJECT ) sqlite3RenameTokenMap(pParse, (void*)z, pName);
executed 2125 times by 1 test: sqlite3RenameTokenMap(pParse, (void*)z, pName);
Executed by:
  • Self test (438)
(pParse->eParseMode>=2)Description
TRUEevaluated 2125 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 419256 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
2125-419256
1079 memcpy(z, pName->z, pName->n);-
1080 z[pName->n] = 0;-
1081 sqlite3Dequote(z);-
1082 for(i=0; i<p->nCol; i++){
i<p->nColDescription
TRUEevaluated 11595724 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 421372 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
421372-11595724
1083 if( sqlite3_stricmp(z, p->aCol[i].zName)==0 ){
sqlite3_stricm...l[i].zName)==0Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11595715 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
9-11595715
1084 sqlite3ErrorMsg(pParse, "duplicate column name: %s", z);-
1085 sqlite3DbFree(db, z);-
1086 return;
executed 9 times by 1 test: return;
Executed by:
  • Self test (438)
9
1087 }-
1088 }
executed 11595715 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
11595715
1089 if( (p->nCol & 0x7)==0 ){
(p->nCol & 0x7)==0Description
TRUEevaluated 103336 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 318036 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
103336-318036
1090 Column *aNew;-
1091 aNew = sqlite3DbRealloc(db,p->aCol,(p->nCol+8)*sizeof(p->aCol[0]));-
1092 if( aNew==0 ){
aNew==0Description
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 103309 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
27-103309
1093 sqlite3DbFree(db, z);-
1094 return;
executed 27 times by 1 test: return;
Executed by:
  • Self test (438)
27
1095 }-
1096 p->aCol = aNew;-
1097 }
executed 103309 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
103309
1098 pCol = &p->aCol[p->nCol];-
1099 memset(pCol, 0, sizeof(p->aCol[0]));-
1100 pCol->zName = z;-
1101 sqlite3ColumnPropertiesFromName(p, pCol);-
1102 -
1103 if( pType->n==0 ){
pType->n==0Description
TRUEevaluated 151417 times by 102 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • ...
FALSEevaluated 269928 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
151417-269928
1104 /* If there is no type specified, columns have the default affinity-
1105 ** 'BLOB' with a default size of 4 bytes. */-
1106 pCol->affinity = SQLITE_AFF_BLOB;-
1107 pCol->szEst = 1;-
1108#ifdef SQLITE_ENABLE_SORTER_REFERENCES-
1109 if( 4>=sqlite3GlobalConfig.szSorterRef ){-
1110 pCol->colFlags |= COLFLAG_SORTERREF;-
1111 }-
1112#endif-
1113 }else{
executed 151417 times by 102 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • ...
151417
1114 zType = z + sqlite3Strlen30(z) + 1;-
1115 memcpy(zType, pType->z, pType->n);-
1116 zType[pType->n] = 0;-
1117 sqlite3Dequote(zType);-
1118 pCol->affinity = sqlite3AffinityType(zType, pCol);-
1119 pCol->colFlags |= COLFLAG_HASTYPE;-
1120 }
executed 269928 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
269928
1121 p->nCol++;-
1122 pParse->constraintName.n = 0;-
1123}
executed 421345 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
421345
1124-
1125/*-
1126** This routine is called by the parser while in the middle of-
1127** parsing a CREATE TABLE statement. A "NOT NULL" constraint has-
1128** been seen on a column. This routine sets the notNull flag on-
1129** the column currently under construction.-
1130*/-
1131void sqlite3AddNotNull(Parse *pParse, int onError){-
1132 Table *p;-
1133 Column *pCol;-
1134 p = pParse->pNewTable;-
1135 if( p==0 || NEVER(p->nCol<1) ) return;
never executed: return;
p==0Description
TRUEnever evaluated
FALSEevaluated 1551 times by 1 test
Evaluated by:
  • Self test (438)
(p->nCol<1)Description
TRUEnever evaluated
FALSEevaluated 1551 times by 1 test
Evaluated by:
  • Self test (438)
0-1551
1136 pCol = &p->aCol[p->nCol-1];-
1137 pCol->notNull = (u8)onError;-
1138 p->tabFlags |= TF_HasNotNull;-
1139-
1140 /* Set the uniqNotNull flag on any UNIQUE or PK indexes already created-
1141 ** on this column. */-
1142 if( pCol->colFlags & COLFLAG_UNIQUE ){
pCol->colFlags & 0x0008Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1486 times by 1 test
Evaluated by:
  • Self test (438)
65-1486
1143 Index *pIdx;-
1144 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 70 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 65 times by 1 test
Evaluated by:
  • Self test (438)
65-70
1145 assert( pIdx->nKeyCol==1 && pIdx->onError!=OE_None );-
1146 if( pIdx->aiColumn[0]==p->nCol-1 ){
pIdx->aiColumn[0]==p->nCol-1Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
5-65
1147 pIdx->uniqNotNull = 1;-
1148 }
executed 65 times by 1 test: end of block
Executed by:
  • Self test (438)
65
1149 }
executed 70 times by 1 test: end of block
Executed by:
  • Self test (438)
70
1150 }
executed 65 times by 1 test: end of block
Executed by:
  • Self test (438)
65
1151}
executed 1551 times by 1 test: end of block
Executed by:
  • Self test (438)
1551
1152-
1153/*-
1154** Scan the column type name zType (length nType) and return the-
1155** associated affinity type.-
1156**-
1157** This routine does a case-independent search of zType for the -
1158** substrings in the following table. If one of the substrings is-
1159** found, the corresponding affinity is returned. If zType contains-
1160** more than one of the substrings, entries toward the top of -
1161** the table take priority. For example, if zType is 'BLOBINT', -
1162** SQLITE_AFF_INTEGER is returned.-
1163**-
1164** Substring | Affinity-
1165** ---------------------------------
1166** 'INT' | SQLITE_AFF_INTEGER-
1167** 'CHAR' | SQLITE_AFF_TEXT-
1168** 'CLOB' | SQLITE_AFF_TEXT-
1169** 'TEXT' | SQLITE_AFF_TEXT-
1170** 'BLOB' | SQLITE_AFF_BLOB-
1171** 'REAL' | SQLITE_AFF_REAL-
1172** 'FLOA' | SQLITE_AFF_REAL-
1173** 'DOUB' | SQLITE_AFF_REAL-
1174**-
1175** If none of the substrings in the above table are found,-
1176** SQLITE_AFF_NUMERIC is returned.-
1177*/-
1178char sqlite3AffinityType(const char *zIn, Column *pCol){-
1179 u32 h = 0;-
1180 char aff = SQLITE_AFF_NUMERIC;-
1181 const char *zChar = 0;-
1182-
1183 assert( zIn!=0 );-
1184 while( zIn[0] ){
zIn[0]Description
TRUEevaluated 1081246 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 212604 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
212604-1081246
1185 h = (h<<8) + sqlite3UpperToLower[(*zIn)&0xff];-
1186 zIn++;-
1187 if( h==(('c'<<24)+('h'<<16)+('a'<<8)+'r') ){ /* CHAR */
h==(('c'<<24)+...+('a'<<8)+'r')Description
TRUEevaluated 505 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1080741 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
505-1080741
1188 aff = SQLITE_AFF_TEXT;-
1189 zChar = zIn;-
1190 }else if( h==(('c'<<24)+('l'<<16)+('o'<<8)+'b') ){ /* CLOB */
executed 505 times by 1 test: end of block
Executed by:
  • Self test (438)
h==(('c'<<24)+...+('o'<<8)+'b')Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1080736 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
5-1080736
1191 aff = SQLITE_AFF_TEXT;-
1192 }else if( h==(('t'<<24)+('e'<<16)+('x'<<8)+'t') ){ /* TEXT */
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
h==(('t'<<24)+...+('x'<<8)+'t')Description
TRUEevaluated 191576 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 889160 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
5-889160
1193 aff = SQLITE_AFF_TEXT;-
1194 }else if( h==(('b'<<24)+('l'<<16)+('o'<<8)+'b') /* BLOB */
executed 191576 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
h==(('b'<<24)+...+('o'<<8)+'b')Description
TRUEevaluated 1602 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
FALSEevaluated 887558 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1602-887558
1195 && (aff==SQLITE_AFF_NUMERIC || aff==SQLITE_AFF_REAL) ){
aff=='C'Description
TRUEevaluated 1602 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
FALSEnever evaluated
aff=='E'Description
TRUEnever evaluated
FALSEnever evaluated
0-1602
1196 aff = SQLITE_AFF_BLOB;-
1197 if( zIn[0]=='(' ) zChar = zIn;
never executed: zChar = zIn;
zIn[0]=='('Description
TRUEnever evaluated
FALSEevaluated 1602 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
0-1602
1198#ifndef SQLITE_OMIT_FLOATING_POINT-
1199 }else if( h==(('r'<<24)+('e'<<16)+('a'<<8)+'l') /* REAL */
executed 1602 times by 333 tests: end of block
Executed by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
h==(('r'<<24)+...+('a'<<8)+'l')Description
TRUEevaluated 1011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 886547 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1011-886547
1200 && aff==SQLITE_AFF_NUMERIC ){
aff=='C'Description
TRUEevaluated 1011 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-1011
1201 aff = SQLITE_AFF_REAL;-
1202 }else if( h==(('f'<<24)+('l'<<16)+('o'<<8)+'a') /* FLOA */
executed 1011 times by 1 test: end of block
Executed by:
  • Self test (438)
h==(('f'<<24)+...+('o'<<8)+'a')Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 886475 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
72-886475
1203 && aff==SQLITE_AFF_NUMERIC ){
aff=='C'Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-72
1204 aff = SQLITE_AFF_REAL;-
1205 }else if( h==(('d'<<24)+('o'<<16)+('u'<<8)+'b') /* DOUB */
executed 72 times by 1 test: end of block
Executed by:
  • Self test (438)
h==(('d'<<24)+...+('u'<<8)+'b')Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 886461 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
14-886461
1206 && aff==SQLITE_AFF_NUMERIC ){
aff=='C'Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-14
1207 aff = SQLITE_AFF_REAL;-
1208#endif-
1209 }else if( (h&0x00FFFFFF)==(('i'<<16)+('n'<<8)+'t') ){ /* INT */
executed 14 times by 1 test: end of block
Executed by:
  • Self test (438)
(h&0x00FFFFFF)...+('n'<<8)+'t')Description
TRUEevaluated 62844 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 823617 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
14-823617
1210 aff = SQLITE_AFF_INTEGER;-
1211 break;
executed 62844 times by 436 tests: break;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
62844
1212 }-
1213 }
executed 1018402 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1018402
1214-
1215 /* If pCol is not NULL, store an estimate of the field size. The-
1216 ** estimate is scaled so that the size of an integer is 1. */-
1217 if( pCol ){
pColDescription
TRUEevaluated 269928 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 5520 times by 1 test
Evaluated by:
  • Self test (438)
5520-269928
1218 int v = 0; /* default size is approx 4 bytes */-
1219 if( aff<SQLITE_AFF_NUMERIC ){
aff<'C'Description
TRUEevaluated 193286 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 76642 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
76642-193286
1220 if( zChar ){
zCharDescription
TRUEevaluated 496 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 192790 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
496-192790
1221 while( zChar[0] ){
zChar[0]Description
TRUEevaluated 890 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 80 times by 1 test
Evaluated by:
  • Self test (438)
80-890
1222 if( sqlite3Isdigit(zChar[0]) ){
(sqlite3CtypeM...har[0])]&0x04)Description
TRUEevaluated 416 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 474 times by 1 test
Evaluated by:
  • Self test (438)
416-474
1223 /* BLOB(k), VARCHAR(k), CHAR(k) -> r=(k/4+1) */-
1224 sqlite3GetInt32(zChar, &v);-
1225 break;
executed 416 times by 1 test: break;
Executed by:
  • Self test (438)
416
1226 }-
1227 zChar++;-
1228 }
executed 474 times by 1 test: end of block
Executed by:
  • Self test (438)
474
1229 }else{
executed 496 times by 1 test: end of block
Executed by:
  • Self test (438)
496
1230 v = 16; /* BLOB, TEXT, CLOB -> r=5 (approx 20 bytes)*/-
1231 }
executed 192790 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
192790
1232 }-
1233#ifdef SQLITE_ENABLE_SORTER_REFERENCES-
1234 if( v>=sqlite3GlobalConfig.szSorterRef ){-
1235 pCol->colFlags |= COLFLAG_SORTERREF;-
1236 }-
1237#endif-
1238 v = v/4 + 1;-
1239 if( v>255 ) v = 255;
never executed: v = 255;
v>255Description
TRUEnever evaluated
FALSEevaluated 269928 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
0-269928
1240 pCol->szEst = v;-
1241 }
executed 269928 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
269928
1242 return aff;
executed 275448 times by 436 tests: return aff;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
275448
1243}-
1244-
1245/*-
1246** The expression is the default value for the most recently added column-
1247** of the table currently under construction.-
1248**-
1249** Default value expressions must be constant. Raise an exception if this-
1250** is not the case.-
1251**-
1252** This routine is called by the parser while in the middle of-
1253** parsing a CREATE TABLE statement.-
1254*/-
1255void sqlite3AddDefaultValue(-
1256 Parse *pParse, /* Parsing context */-
1257 Expr *pExpr, /* The parsed expression of the default value */-
1258 const char *zStart, /* Start of the default value text */-
1259 const char *zEnd /* First character past end of defaut value text */-
1260){-
1261 Table *p;-
1262 Column *pCol;-
1263 sqlite3 *db = pParse->db;-
1264 p = pParse->pNewTable;-
1265 if( p!=0 ){
p!=0Description
TRUEevaluated 1590 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-1590
1266 pCol = &(p->aCol[p->nCol-1]);-
1267 if( !sqlite3ExprIsConstantOrFunction(pExpr, db->init.busy) ){
!sqlite3ExprIs...db->init.busy)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1585 times by 1 test
Evaluated by:
  • Self test (438)
5-1585
1268 sqlite3ErrorMsg(pParse, "default value of column [%s] is not constant",-
1269 pCol->zName);-
1270 }else{
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
5
1271 /* A copy of pExpr is used instead of the original, as pExpr contains-
1272 ** tokens that point to volatile memory.-
1273 */-
1274 Expr x;-
1275 sqlite3ExprDelete(db, pCol->pDflt);-
1276 memset(&x, 0, sizeof(x));-
1277 x.op = TK_SPAN;-
1278 x.u.zToken = sqlite3DbSpanDup(db, zStart, zEnd);-
1279 x.pLeft = pExpr;-
1280 x.flags = EP_Skip;-
1281 pCol->pDflt = sqlite3ExprDup(db, &x, EXPRDUP_REDUCE);-
1282 sqlite3DbFree(db, x.u.zToken);-
1283 }
executed 1585 times by 1 test: end of block
Executed by:
  • Self test (438)
1585
1284 }-
1285 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 24 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1566 times by 1 test
Evaluated by:
  • Self test (438)
24-1566
1286 sqlite3RenameExprUnmap(pParse, pExpr);-
1287 }
executed 24 times by 1 test: end of block
Executed by:
  • Self test (438)
24
1288 sqlite3ExprDelete(db, pExpr);-
1289}
executed 1590 times by 1 test: end of block
Executed by:
  • Self test (438)
1590
1290-
1291/*-
1292** Backwards Compatibility Hack:-
1293** -
1294** Historical versions of SQLite accepted strings as column names in-
1295** indexes and PRIMARY KEY constraints and in UNIQUE constraints. Example:-
1296**-
1297** CREATE TABLE xyz(a,b,c,d,e,PRIMARY KEY('a'),UNIQUE('b','c' COLLATE trim)-
1298** CREATE INDEX abc ON xyz('c','d' DESC,'e' COLLATE nocase DESC);-
1299**-
1300** This is goofy. But to preserve backwards compatibility we continue to-
1301** accept it. This routine does the necessary conversion. It converts-
1302** the expression given in its argument from a TK_STRING into a TK_ID-
1303** if the expression is just a TK_STRING with an optional COLLATE clause.-
1304** If the epxression is anything other than TK_STRING, the expression is-
1305** unchanged.-
1306*/-
1307static void sqlite3StringToId(Expr *p){-
1308 if( p->op==TK_STRING ){
p->op==106Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 21792 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
47-21792
1309 p->op = TK_ID;-
1310 }else if( p->op==TK_COLLATE && p->pLeft->op==TK_STRING ){
executed 47 times by 1 test: end of block
Executed by:
  • Self test (438)
p->op==102Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 21634 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
p->pLeft->op==106Description
TRUEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 145 times by 1 test
Evaluated by:
  • Self test (438)
13-21634
1311 p->pLeft->op = TK_ID;-
1312 }
executed 13 times by 1 test: end of block
Executed by:
  • Self test (438)
13
1313}
executed 21839 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
21839
1314-
1315/*-
1316** Designate the PRIMARY KEY for the table. pList is a list of names -
1317** of columns that form the primary key. If pList is NULL, then the-
1318** most recently added column of the table is the primary key.-
1319**-
1320** A table can have at most one primary key. If the table already has-
1321** a primary key (and this is the second primary key) then create an-
1322** error.-
1323**-
1324** If the PRIMARY KEY is on a single column whose datatype is INTEGER,-
1325** then we will try to use that column as the rowid. Set the Table.iPKey-
1326** field of the table under construction to be the index of the-
1327** INTEGER PRIMARY KEY column. Table.iPKey is set to -1 if there is-
1328** no INTEGER PRIMARY KEY.-
1329**-
1330** If the key is not an INTEGER PRIMARY KEY, then create a unique-
1331** index for the key. No index is created for INTEGER PRIMARY KEYs.-
1332*/-
1333void sqlite3AddPrimaryKey(-
1334 Parse *pParse, /* Parsing context */-
1335 ExprList *pList, /* List of field names to be indexed */-
1336 int onError, /* What to do with a uniqueness conflict */-
1337 int autoInc, /* True if the AUTOINCREMENT keyword is present */-
1338 int sortOrder /* SQLITE_SO_ASC or SQLITE_SO_DESC */-
1339){-
1340 Table *pTab = pParse->pNewTable;-
1341 Column *pCol = 0;-
1342 int iCol = -1, i;-
1343 int nTerm;-
1344 if( pTab==0 ) goto primary_key_exit;
executed 1 time by 1 test: goto primary_key_exit;
Executed by:
  • Self test (438)
pTab==0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 16235 times by 353 tests
Evaluated by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
1-16235
1345 if( pTab->tabFlags & TF_HasPrimaryKey ){
pTab->tabFlags & 0x0004Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 16225 times by 353 tests
Evaluated by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
10-16225
1346 sqlite3ErrorMsg(pParse, -
1347 "table \"%s\" has more than one primary key", pTab->zName);-
1348 goto primary_key_exit;
executed 10 times by 1 test: goto primary_key_exit;
Executed by:
  • Self test (438)
10
1349 }-
1350 pTab->tabFlags |= TF_HasPrimaryKey;-
1351 if( pList==0 ){
pList==0Description
TRUEevaluated 15300 times by 353 tests
Evaluated by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
FALSEevaluated 925 times by 1 test
Evaluated by:
  • Self test (438)
925-15300
1352 iCol = pTab->nCol - 1;-
1353 pCol = &pTab->aCol[iCol];-
1354 pCol->colFlags |= COLFLAG_PRIMKEY;-
1355 nTerm = 1;-
1356 }else{
executed 15300 times by 353 tests: end of block
Executed by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
15300
1357 nTerm = pList->nExpr;-
1358 for(i=0; i<nTerm; i++){
i<nTermDescription
TRUEevaluated 2388 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 925 times by 1 test
Evaluated by:
  • Self test (438)
925-2388
1359 Expr *pCExpr = sqlite3ExprSkipCollate(pList->a[i].pExpr);-
1360 assert( pCExpr!=0 );-
1361 sqlite3StringToId(pCExpr);-
1362 if( pCExpr->op==TK_ID ){
pCExpr->op==59Description
TRUEevaluated 2386 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-2386
1363 const char *zCName = pCExpr->u.zToken;-
1364 for(iCol=0; iCol<pTab->nCol; iCol++){
iCol<pTab->nColDescription
TRUEevaluated 6156 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-6156
1365 if( sqlite3StrICmp(zCName, pTab->aCol[iCol].zName)==0 ){
sqlite3StrICmp...Col].zName)==0Description
TRUEevaluated 2384 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3772 times by 1 test
Evaluated by:
  • Self test (438)
2384-3772
1366 pCol = &pTab->aCol[iCol];-
1367 pCol->colFlags |= COLFLAG_PRIMKEY;-
1368 break;
executed 2384 times by 1 test: break;
Executed by:
  • Self test (438)
2384
1369 }-
1370 }
executed 3772 times by 1 test: end of block
Executed by:
  • Self test (438)
3772
1371 }
executed 2386 times by 1 test: end of block
Executed by:
  • Self test (438)
2386
1372 }
executed 2388 times by 1 test: end of block
Executed by:
  • Self test (438)
2388
1373 }
executed 925 times by 1 test: end of block
Executed by:
  • Self test (438)
925
1374 if( nTerm==1
nTerm==1Description
TRUEevaluated 15539 times by 353 tests
Evaluated by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
FALSEevaluated 686 times by 1 test
Evaluated by:
  • Self test (438)
686-15539
1375 && pCol
pColDescription
TRUEevaluated 15538 times by 353 tests
Evaluated by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-15538
1376 && sqlite3StrICmp(sqlite3ColumnType(pCol,""), "INTEGER")==0
sqlite3StrICmp... "INTEGER")==0Description
TRUEevaluated 13446 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
FALSEevaluated 2092 times by 21 tests
Evaluated by:
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
2092-13446
1377 && sortOrder!=SQLITE_SO_DESC
sortOrder!=1Description
TRUEevaluated 13442 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-13442
1378 ){-
1379 if( IN_RENAME_OBJECT && pList ){
(pParse->eParseMode>=2)Description
TRUEevaluated 72 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13370 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
pListDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test (438)
27-13370
1380 sqlite3RenameTokenRemap(pParse, &pTab->iPKey, pList->a[0].pExpr);-
1381 }
executed 27 times by 1 test: end of block
Executed by:
  • Self test (438)
27
1382 pTab->iPKey = iCol;-
1383 pTab->keyConf = (u8)onError;-
1384 assert( autoInc==0 || autoInc==1 );-
1385 pTab->tabFlags |= autoInc*TF_Autoincrement;-
1386 if( pList ) pParse->iPkSortOrder = pList->a[0].sortOrder;
executed 107 times by 1 test: pParse->iPkSortOrder = pList->a[0].sortOrder;
Executed by:
  • Self test (438)
pListDescription
TRUEevaluated 107 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13335 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
107-13335
1387 }else if( autoInc ){
executed 13442 times by 333 tests: end of block
Executed by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
autoIncDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2782 times by 21 tests
Evaluated by:
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
1-13442
1388#ifndef SQLITE_OMIT_AUTOINCREMENT-
1389 sqlite3ErrorMsg(pParse, "AUTOINCREMENT is only allowed on an "-
1390 "INTEGER PRIMARY KEY");-
1391#endif-
1392 }else{
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
1
1393 sqlite3CreateIndex(pParse, 0, 0, 0, pList, onError, 0,-
1394 0, sortOrder, 0, SQLITE_IDXTYPE_PRIMARYKEY);-
1395 pList = 0;-
1396 }
executed 2782 times by 21 tests: end of block
Executed by:
  • Self test (10)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (6)
  • Self test (7)
  • Self test (8)
  • Self test (9)
2782
1397-
1398primary_key_exit:
code before this statement executed 16225 times by 353 tests: primary_key_exit:
Executed by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
16225
1399 sqlite3ExprListDelete(pParse->db, pList);-
1400 return;
executed 16236 times by 353 tests: return;
Executed by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • ...
16236
1401}-
1402-
1403/*-
1404** Add a new CHECK constraint to the table currently under construction.-
1405*/-
1406void sqlite3AddCheckConstraint(-
1407 Parse *pParse, /* Parsing context */-
1408 Expr *pCheckExpr /* The check expression */-
1409){-
1410#ifndef SQLITE_OMIT_CHECK-
1411 Table *pTab = pParse->pNewTable;-
1412 sqlite3 *db = pParse->db;-
1413 if( pTab && !IN_DECLARE_VTAB
pTabDescription
TRUEevaluated 365 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
!(pParse->eParseMode==1)Description
TRUEevaluated 365 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-365
1414 && !sqlite3BtreeIsReadonly(db->aDb[db->init.iDb].pBt)
!sqlite3BtreeI...init.iDb].pBt)Description
TRUEevaluated 365 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-365
1415 ){-
1416 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);-
1417 if( pParse->constraintName.n ){
pParse->constraintName.nDescription
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 335 times by 1 test
Evaluated by:
  • Self test (438)
30-335
1418 sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);-
1419 }
executed 30 times by 1 test: end of block
Executed by:
  • Self test (438)
30
1420 }else
executed 365 times by 1 test: end of block
Executed by:
  • Self test (438)
365
1421#endif-
1422 {-
1423 sqlite3ExprDelete(pParse->db, pCheckExpr);-
1424 }
never executed: end of block
0
1425}-
1426-
1427/*-
1428** Set the collation function of the most recently parsed table column-
1429** to the CollSeq given.-
1430*/-
1431void sqlite3AddCollateType(Parse *pParse, Token *pToken){-
1432 Table *p;-
1433 int i;-
1434 char *zColl; /* Dequoted name of collation sequence */-
1435 sqlite3 *db;-
1436-
1437 if( (p = pParse->pNewTable)==0 ) return;
never executed: return;
(p = pParse->pNewTable)==0Description
TRUEnever evaluated
FALSEevaluated 569 times by 1 test
Evaluated by:
  • Self test (438)
0-569
1438 i = p->nCol-1;-
1439 db = pParse->db;-
1440 zColl = sqlite3NameFromToken(db, pToken);-
1441 if( !zColl ) return;
never executed: return;
!zCollDescription
TRUEnever evaluated
FALSEevaluated 569 times by 1 test
Evaluated by:
  • Self test (438)
0-569
1442-
1443 if( sqlite3LocateCollSeq(pParse, zColl) ){
sqlite3LocateC...pParse, zColl)Description
TRUEevaluated 565 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-565
1444 Index *pIdx;-
1445 sqlite3DbFree(db, p->aCol[i].zColl);-
1446 p->aCol[i].zColl = zColl;-
1447 -
1448 /* If the column is declared as "<name> PRIMARY KEY COLLATE <type>",-
1449 ** then an index may have been created on this column before the-
1450 ** collation type was added. Correct this if it is the case.-
1451 */-
1452 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 96 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 565 times by 1 test
Evaluated by:
  • Self test (438)
96-565
1453 assert( pIdx->nKeyCol==1 );-
1454 if( pIdx->aiColumn[0]==i ){
pIdx->aiColumn[0]==iDescription
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 37 times by 1 test
Evaluated by:
  • Self test (438)
37-59
1455 pIdx->azColl[0] = p->aCol[i].zColl;-
1456 }
executed 59 times by 1 test: end of block
Executed by:
  • Self test (438)
59
1457 }
executed 96 times by 1 test: end of block
Executed by:
  • Self test (438)
96
1458 }else{
executed 565 times by 1 test: end of block
Executed by:
  • Self test (438)
565
1459 sqlite3DbFree(db, zColl);-
1460 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test (438)
4
1461}-
1462-
1463/*-
1464** This function returns the collation sequence for database native text-
1465** encoding identified by the string zName, length nName.-
1466**-
1467** If the requested collation sequence is not available, or not available-
1468** in the database native encoding, the collation factory is invoked to-
1469** request it. If the collation factory does not supply such a sequence,-
1470** and the sequence is available in another text encoding, then that is-
1471** returned instead.-
1472**-
1473** If no versions of the requested collations sequence are available, or-
1474** another error occurs, NULL is returned and an error message written into-
1475** pParse.-
1476**-
1477** This routine is a wrapper around sqlite3FindCollSeq(). This routine-
1478** invokes the collation factory if the named collation cannot be found-
1479** and generates an error message.-
1480**-
1481** See also: sqlite3FindCollSeq(), sqlite3GetCollSeq()-
1482*/-
1483CollSeq *sqlite3LocateCollSeq(Parse *pParse, const char *zName){-
1484 sqlite3 *db = pParse->db;-
1485 u8 enc = ENC(db);-
1486 u8 initbusy = db->init.busy;-
1487 CollSeq *pColl;-
1488-
1489 pColl = sqlite3FindCollSeq(db, enc, zName, initbusy);-
1490 if( !initbusy && (!pColl || !pColl->xCmp) ){
!initbusyDescription
TRUEevaluated 12047 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 281 times by 1 test
Evaluated by:
  • Self test (438)
!pCollDescription
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 12037 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
!pColl->xCmpDescription
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 12015 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
10-12047
1491 pColl = sqlite3GetCollSeq(pParse, enc, pColl, zName);-
1492 }
executed 32 times by 1 test: end of block
Executed by:
  • Self test (438)
32
1493-
1494 return pColl;
executed 12328 times by 22 tests: return pColl;
Executed by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
12328
1495}-
1496-
1497-
1498/*-
1499** Generate code that will increment the schema cookie.-
1500**-
1501** The schema cookie is used to determine when the schema for the-
1502** database changes. After each schema change, the cookie value-
1503** changes. When a process first reads the schema it records the-
1504** cookie. Thereafter, whenever it goes to access the database,-
1505** it checks the cookie to make sure the schema has not changed-
1506** since it was last read.-
1507**-
1508** This plan is not completely bullet-proof. It is possible for-
1509** the schema to change multiple times and for the cookie to be-
1510** set back to prior value. But schema changes are infrequent-
1511** and the probability of hitting the same cookie value is only-
1512** 1 chance in 2^32. So we're safe enough.-
1513**-
1514** IMPLEMENTATION-OF: R-34230-56049 SQLite automatically increments-
1515** the schema-version whenever the schema changes.-
1516*/-
1517void sqlite3ChangeCookie(Parse *pParse, int iDb){-
1518 sqlite3 *db = pParse->db;-
1519 Vdbe *v = pParse->pVdbe;-
1520 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
1521 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION, -
1522 (int)(1+(unsigned)db->aDb[iDb].pSchema->schema_cookie));-
1523}
executed 33192 times by 33 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • ...
33192
1524-
1525/*-
1526** Measure the number of characters needed to output the given-
1527** identifier. The number returned includes any quotes used-
1528** but does not include the null terminator.-
1529**-
1530** The estimate is conservative. It might be larger that what is-
1531** really needed.-
1532*/-
1533static int identLength(const char *z){-
1534 int n;-
1535 for(n=0; *z; n++, z++){
*zDescription
TRUEevaluated 759 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 386 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
386-759
1536 if( *z=='"' ){ n++; }
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
*z=='"'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 758 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
1-758
1537 }
executed 759 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
759
1538 return n + 2;
executed 386 times by 4 tests: return n + 2;
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
386
1539}-
1540-
1541/*-
1542** The first parameter is a pointer to an output buffer. The second -
1543** parameter is a pointer to an integer that contains the offset at-
1544** which to write into the output buffer. This function copies the-
1545** nul-terminated string pointed to by the third parameter, zSignedIdent,-
1546** to the specified offset in the buffer and updates *pIdx to refer-
1547** to the first byte after the last byte written before returning.-
1548** -
1549** If the string zSignedIdent consists entirely of alpha-numeric-
1550** characters, does not begin with a digit and is not an SQL keyword,-
1551** then it is copied to the output buffer exactly as it is. Otherwise,-
1552** it is quoted using double-quotes.-
1553*/-
1554static void identPut(char *z, int *pIdx, char *zSignedIdent){-
1555 unsigned char *zIdent = (unsigned char*)zSignedIdent;-
1556 int i, j, needQuote;-
1557 i = *pIdx;-
1558-
1559 for(j=0; zIdent[j]; j++){
zIdent[j]Description
TRUEevaluated 656 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 337 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
337-656
1560 if( !sqlite3Isalnum(zIdent[j]) && zIdent[j]!='_' ) break;
executed 49 times by 1 test: break;
Executed by:
  • Self test (438)
!(sqlite3Ctype...ent[j])]&0x06)Description
TRUEevaluated 53 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 603 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
zIdent[j]!='_'Description
TRUEevaluated 49 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-603
1561 }
executed 607 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
607
1562 needQuote = sqlite3Isdigit(zIdent[0])
(sqlite3CtypeM...ent[0])]&0x04)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 382 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
4-382
1563 || sqlite3KeywordCode(zIdent, j)!=TK_ID
sqlite3Keyword...zIdent, j)!=59Description
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 375 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
7-375
1564 || zIdent[j]!=0
zIdent[j]!=0Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 328 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
47-328
1565 || j==0;
j==0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 326 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
2-326
1566-
1567 if( needQuote ) z[i++] = '"';
executed 60 times by 1 test: z[i++] = '"';
Executed by:
  • Self test (438)
needQuoteDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 326 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
60-326
1568 for(j=0; zIdent[j]; j++){
zIdent[j]Description
TRUEevaluated 759 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 386 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
386-759
1569 z[i++] = zIdent[j];-
1570 if( zIdent[j]=='"' ) z[i++] = '"';
executed 1 time by 1 test: z[i++] = '"';
Executed by:
  • Self test (438)
zIdent[j]=='"'Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 758 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
1-758
1571 }
executed 759 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
759
1572 if( needQuote ) z[i++] = '"';
executed 60 times by 1 test: z[i++] = '"';
Executed by:
  • Self test (438)
needQuoteDescription
TRUEevaluated 60 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 326 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
60-326
1573 z[i] = 0;-
1574 *pIdx = i;-
1575}
executed 386 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
386
1576-
1577/*-
1578** Generate a CREATE TABLE statement appropriate for the given-
1579** table. Memory to hold the text of the statement is obtained-
1580** from sqliteMalloc() and must be freed by the calling function.-
1581*/-
1582static char *createTableStmt(sqlite3 *db, Table *p){-
1583 int i, k, n;-
1584 char *zStmt;-
1585 char *zSep, *zSep2, *zEnd;-
1586 Column *pCol;-
1587 n = 0;-
1588 for(pCol = p->aCol, i=0; i<p->nCol; i++, pCol++){
i<p->nColDescription
TRUEevaluated 265 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 121 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
121-265
1589 n += identLength(pCol->zName) + 5;-
1590 }
executed 265 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
265
1591 n += identLength(p->zName);-
1592 if( n<50 ){
n<50Description
TRUEevaluated 117 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-117
1593 zSep = "";-
1594 zSep2 = ",";-
1595 zEnd = ")";-
1596 }else{
executed 117 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
117
1597 zSep = "\n ";-
1598 zSep2 = ",\n ";-
1599 zEnd = "\n)";-
1600 }
executed 4 times by 1 test: end of block
Executed by:
  • Self test (438)
4
1601 n += 35 + 6*p->nCol;-
1602 zStmt = sqlite3DbMallocRaw(0, n);-
1603 if( zStmt==0 ){
zStmt==0Description
TRUEnever evaluated
FALSEevaluated 121 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
0-121
1604 sqlite3OomFault(db);-
1605 return 0;
never executed: return 0;
0
1606 }-
1607 sqlite3_snprintf(n, zStmt, "CREATE TABLE ");-
1608 k = sqlite3Strlen30(zStmt);-
1609 identPut(zStmt, &k, p->zName);-
1610 zStmt[k++] = '(';-
1611 for(pCol=p->aCol, i=0; i<p->nCol; i++, pCol++){
i<p->nColDescription
TRUEevaluated 265 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 121 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
121-265
1612 static const char * const azType[] = {-
1613 /* SQLITE_AFF_BLOB */ "",-
1614 /* SQLITE_AFF_TEXT */ " TEXT",-
1615 /* SQLITE_AFF_NUMERIC */ " NUM",-
1616 /* SQLITE_AFF_INTEGER */ " INT",-
1617 /* SQLITE_AFF_REAL */ " REAL"-
1618 };-
1619 int len;-
1620 const char *zType;-
1621-
1622 sqlite3_snprintf(n-k, &zStmt[k], zSep);-
1623 k += sqlite3Strlen30(&zStmt[k]);-
1624 zSep = zSep2;-
1625 identPut(zStmt, &k, pCol->zName);-
1626 assert( pCol->affinity-SQLITE_AFF_BLOB >= 0 );-
1627 assert( pCol->affinity-SQLITE_AFF_BLOB < ArraySize(azType) );-
1628 testcase( pCol->affinity==SQLITE_AFF_BLOB );-
1629 testcase( pCol->affinity==SQLITE_AFF_TEXT );-
1630 testcase( pCol->affinity==SQLITE_AFF_NUMERIC );-
1631 testcase( pCol->affinity==SQLITE_AFF_INTEGER );-
1632 testcase( pCol->affinity==SQLITE_AFF_REAL );-
1633 -
1634 zType = azType[pCol->affinity - SQLITE_AFF_BLOB];-
1635 len = sqlite3Strlen30(zType);-
1636 assert( pCol->affinity==SQLITE_AFF_BLOB -
1637 || pCol->affinity==sqlite3AffinityType(zType, 0) );-
1638 memcpy(&zStmt[k], zType, len);-
1639 k += len;-
1640 assert( k<=n );-
1641 }
executed 265 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
265
1642 sqlite3_snprintf(n-k, &zStmt[k], "%s", zEnd);-
1643 return zStmt;
executed 121 times by 4 tests: return zStmt;
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
121
1644}-
1645-
1646/*-
1647** Resize an Index object to hold N columns total. Return SQLITE_OK-
1648** on success and SQLITE_NOMEM on an OOM error.-
1649*/-
1650static int resizeIndexObject(sqlite3 *db, Index *pIdx, int N){-
1651 char *zExtra;-
1652 int nByte;-
1653 if( pIdx->nColumn>=N ) return SQLITE_OK;
executed 404 times by 1 test: return 0;
Executed by:
  • Self test (438)
pIdx->nColumn>=NDescription
TRUEevaluated 404 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 313 times by 1 test
Evaluated by:
  • Self test (438)
313-404
1654 assert( pIdx->isResized==0 );-
1655 nByte = (sizeof(char*) + sizeof(i16) + 1)*N;-
1656 zExtra = sqlite3DbMallocZero(db, nByte);-
1657 if( zExtra==0 ) return SQLITE_NOMEM_BKPT;
never executed: return 7;
zExtra==0Description
TRUEnever evaluated
FALSEevaluated 313 times by 1 test
Evaluated by:
  • Self test (438)
0-313
1658 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);-
1659 pIdx->azColl = (const char**)zExtra;-
1660 zExtra += sizeof(char*)*N;-
1661 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);-
1662 pIdx->aiColumn = (i16*)zExtra;-
1663 zExtra += sizeof(i16)*N;-
1664 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);-
1665 pIdx->aSortOrder = (u8*)zExtra;-
1666 pIdx->nColumn = N;-
1667 pIdx->isResized = 1;-
1668 return SQLITE_OK;
executed 313 times by 1 test: return 0;
Executed by:
  • Self test (438)
313
1669}-
1670-
1671/*-
1672** Estimate the total row width for a table.-
1673*/-
1674static void estimateTableWidth(Table *pTab){-
1675 unsigned wTable = 0;-
1676 const Column *pTabCol;-
1677 int i;-
1678 for(i=pTab->nCol, pTabCol=pTab->aCol; i>0; i--, pTabCol++){
i>0Description
TRUEevaluated 416207 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 101896 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
101896-416207
1679 wTable += pTabCol->szEst;-
1680 }
executed 416207 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
416207
1681 if( pTab->iPKey<0 ) wTable++;
executed 88519 times by 436 tests: wTable++;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pTab->iPKey<0Description
TRUEevaluated 88519 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 13377 times by 333 tests
Evaluated by:
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • Self test (129)
  • Self test (130)
  • ...
13377-88519
1682 pTab->szTabRow = sqlite3LogEst(wTable*4);-
1683}
executed 101896 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
101896
1684-
1685/*-
1686** Estimate the average size of a row for an index.-
1687*/-
1688static void estimateIndexWidth(Index *pIdx){-
1689 unsigned wIndex = 0;-
1690 int i;-
1691 const Column *aCol = pIdx->pTable->aCol;-
1692 for(i=0; i<pIdx->nColumn; i++){
i<pIdx->nColumnDescription
TRUEevaluated 33167 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 13257 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13257-33167
1693 i16 x = pIdx->aiColumn[i];-
1694 assert( x<pIdx->pTable->nCol );-
1695 wIndex += x<0 ? 1 : aCol[pIdx->aiColumn[i]].szEst;
x<0Description
TRUEevaluated 12342 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 20825 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
12342-20825
1696 }
executed 33167 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
33167
1697 pIdx->szIdxRow = sqlite3LogEst(wIndex*4);-
1698}
executed 13257 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13257
1699-
1700/* Return true if value x is found any of the first nCol entries of aiCol[]-
1701*/-
1702static int hasColumn(const i16 *aiCol, int nCol, int x){-
1703 while( nCol-- > 0 ) if( x==*(aiCol++) ) return 1;
executed 838 times by 1 test: return 1;
Executed by:
  • Self test (438)
x==*(aiCol++)Description
TRUEevaluated 838 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 20158 times by 1 test
Evaluated by:
  • Self test (438)
nCol-- > 0Description
TRUEevaluated 20996 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1943 times by 1 test
Evaluated by:
  • Self test (438)
838-20996
1704 return 0;
executed 1943 times by 1 test: return 0;
Executed by:
  • Self test (438)
1943
1705}-
1706-
1707/* Recompute the colNotIdxed field of the Index.-
1708**-
1709** colNotIdxed is a bitmask that has a 0 bit representing each indexed-
1710** columns that are within the first 63 columns of the table. The-
1711** high-order bit of colNotIdxed is always 1. All unindexed columns-
1712** of the table have a 1.-
1713**-
1714** The colNotIdxed mask is AND-ed with the SrcList.a[].colUsed mask-
1715** to determine if the index is covering index.-
1716*/-
1717static void recomputeColumnsNotIndexed(Index *pIdx){-
1718 Bitmask m = 0;-
1719 int j;-
1720 for(j=pIdx->nColumn-1; j>=0; j--){
j>=0Description
TRUEevaluated 35035 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 14078 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
14078-35035
1721 int x = pIdx->aiColumn[j];-
1722 if( x>=0 ){
x>=0Description
TRUEevaluated 21779 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 13256 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13256-21779
1723 testcase( x==BMS-1 );-
1724 testcase( x==BMS-2 );-
1725 if( x<BMS-1 ) m |= MASKBIT(x);
executed 19552 times by 394 tests: m |= (((Bitmask)1)<<(x));
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
x<((int)(sizeof(Bitmask)*8))-1Description
TRUEevaluated 19552 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 2227 times by 1 test
Evaluated by:
  • Self test (438)
2227-19552
1726 }
executed 21779 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
21779
1727 }
executed 35035 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
35035
1728 pIdx->colNotIdxed = ~m;-
1729 assert( (pIdx->colNotIdxed>>63)==1 );-
1730}
executed 14078 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
14078
1731-
1732/*-
1733** This routine runs at the end of parsing a CREATE TABLE statement that-
1734** has a WITHOUT ROWID clause. The job of this routine is to convert both-
1735** internal schema data structures and the generated VDBE code so that they-
1736** are appropriate for a WITHOUT ROWID table instead of a rowid table.-
1737** Changes include:-
1738**-
1739** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.-
1740** (2) Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY -
1741** into BTREE_BLOBKEY.-
1742** (3) Bypass the creation of the sqlite_master table entry-
1743** for the PRIMARY KEY as the primary key index is now-
1744** identified by the sqlite_master table entry of the table itself.-
1745** (4) Set the Index.tnum of the PRIMARY KEY Index object in the-
1746** schema to the rootpage from the main table.-
1747** (5) Add all table columns to the PRIMARY KEY Index object-
1748** so that the PRIMARY KEY is a covering index. The surplus-
1749** columns are part of KeyInfo.nAllField and are not used for-
1750** sorting or lookup or uniqueness checks.-
1751** (6) Replace the rowid tail on all automatically generated UNIQUE-
1752** indices with the PRIMARY KEY columns.-
1753**-
1754** For virtual tables, only (1) is performed.-
1755*/-
1756static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){-
1757 Index *pIdx;-
1758 Index *pPk;-
1759 int nPk;-
1760 int i, j;-
1761 sqlite3 *db = pParse->db;-
1762 Vdbe *v = pParse->pVdbe;-
1763-
1764 /* Mark every PRIMARY KEY column as NOT NULL (except for imposter tables)-
1765 */-
1766 if( !db->init.imposterTable ){
!db->init.imposterTableDescription
TRUEevaluated 767 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-767
1767 for(i=0; i<pTab->nCol; i++){
i<pTab->nColDescription
TRUEevaluated 2468 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 767 times by 1 test
Evaluated by:
  • Self test (438)
767-2468
1768 if( (pTab->aCol[i].colFlags & COLFLAG_PRIMKEY)!=0 ){
(pTab->aCol[i]...s & 0x0001)!=0Description
TRUEevaluated 981 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1487 times by 1 test
Evaluated by:
  • Self test (438)
981-1487
1769 pTab->aCol[i].notNull = OE_Abort;-
1770 }
executed 981 times by 1 test: end of block
Executed by:
  • Self test (438)
981
1771 }
executed 2468 times by 1 test: end of block
Executed by:
  • Self test (438)
2468
1772 }
executed 767 times by 1 test: end of block
Executed by:
  • Self test (438)
767
1773-
1774 /* The remaining transformations only apply to b-tree tables, not to-
1775 ** virtual tables */-
1776 if( IN_DECLARE_VTAB ) return;
executed 29 times by 1 test: return;
Executed by:
  • Self test (438)
(pParse->eParseMode==1)Description
TRUEevaluated 29 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 739 times by 1 test
Evaluated by:
  • Self test (438)
29-739
1777-
1778 /* Convert the P3 operand of the OP_CreateBtree opcode from BTREE_INTKEY-
1779 ** into BTREE_BLOBKEY.-
1780 */-
1781 if( pParse->addrCrTab ){
pParse->addrCrTabDescription
TRUEevaluated 311 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 428 times by 1 test
Evaluated by:
  • Self test (438)
311-428
1782 assert( v );-
1783 sqlite3VdbeChangeP3(v, pParse->addrCrTab, BTREE_BLOBKEY);-
1784 }
executed 311 times by 1 test: end of block
Executed by:
  • Self test (438)
311
1785-
1786 /* Locate the PRIMARY KEY index. Or, if this table was originally-
1787 ** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index. -
1788 */-
1789 if( pTab->iPKey>=0 ){
pTab->iPKey>=0Description
TRUEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 680 times by 1 test
Evaluated by:
  • Self test (438)
59-680
1790 ExprList *pList;-
1791 Token ipkToken;-
1792 sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);-
1793 pList = sqlite3ExprListAppend(pParse, 0, -
1794 sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));-
1795 if( pList==0 ) return;
never executed: return;
pList==0Description
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
0-59
1796 pList->a[0].sortOrder = pParse->iPkSortOrder;-
1797 assert( pParse->pNewTable==pTab );-
1798 sqlite3CreateIndex(pParse, 0, 0, 0, pList, pTab->keyConf, 0, 0, 0, 0,-
1799 SQLITE_IDXTYPE_PRIMARYKEY);-
1800 if( db->mallocFailed || pParse->nErr ) return;
never executed: return;
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
pParse->nErrDescription
TRUEnever evaluated
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
0-59
1801 pPk = sqlite3PrimaryKeyIndex(pTab);-
1802 pTab->iPKey = -1;-
1803 }else{
executed 59 times by 1 test: end of block
Executed by:
  • Self test (438)
59
1804 pPk = sqlite3PrimaryKeyIndex(pTab);-
1805-
1806 /*-
1807 ** Remove all redundant columns from the PRIMARY KEY. For example, change-
1808 ** "PRIMARY KEY(a,b,a,b,c,b,c,d)" into just "PRIMARY KEY(a,b,c,d)". Later-
1809 ** code assumes the PRIMARY KEY contains no repeated columns.-
1810 */-
1811 for(i=j=1; i<pPk->nKeyCol; i++){
i<pPk->nKeyColDescription
TRUEevaluated 226 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 680 times by 1 test
Evaluated by:
  • Self test (438)
226-680
1812 if( hasColumn(pPk->aiColumn, j, pPk->aiColumn[i]) ){
hasColumn(pPk-...->aiColumn[i])Description
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 214 times by 1 test
Evaluated by:
  • Self test (438)
12-214
1813 pPk->nColumn--;-
1814 }else{
executed 12 times by 1 test: end of block
Executed by:
  • Self test (438)
12
1815 pPk->aiColumn[j++] = pPk->aiColumn[i];-
1816 }
executed 214 times by 1 test: end of block
Executed by:
  • Self test (438)
214
1817 }-
1818 pPk->nKeyCol = j;-
1819 }
executed 680 times by 1 test: end of block
Executed by:
  • Self test (438)
680
1820 assert( pPk!=0 );-
1821 pPk->isCovering = 1;-
1822 if( !db->init.imposterTable ) pPk->uniqNotNull = 1;
executed 738 times by 1 test: pPk->uniqNotNull = 1;
Executed by:
  • Self test (438)
!db->init.imposterTableDescription
TRUEevaluated 738 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-738
1823 nPk = pPk->nKeyCol;-
1824-
1825 /* Bypass the creation of the PRIMARY KEY btree and the sqlite_master-
1826 ** table entry. This is only required if currently generating VDBE-
1827 ** code for a CREATE TABLE (not when parsing one as part of reading-
1828 ** a database schema). */-
1829 if( v && pPk->tnum>0 ){
vDescription
TRUEevaluated 311 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 428 times by 1 test
Evaluated by:
  • Self test (438)
pPk->tnum>0Description
TRUEevaluated 269 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test (438)
42-428
1830 assert( db->init.busy==0 );-
1831 sqlite3VdbeChangeOpcode(v, pPk->tnum, OP_Goto);-
1832 }
executed 269 times by 1 test: end of block
Executed by:
  • Self test (438)
269
1833-
1834 /* The root page of the PRIMARY KEY is the table root page */-
1835 pPk->tnum = pTab->tnum;-
1836-
1837 /* Update the in-memory representation of all UNIQUE indices by converting-
1838 ** the final rowid column into one or more columns of the PRIMARY KEY.-
1839 */-
1840 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 832 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 739 times by 1 test
Evaluated by:
  • Self test (438)
739-832
1841 int n;-
1842 if( IsPrimaryKeyIndex(pIdx) ) continue;
executed 739 times by 1 test: continue;
Executed by:
  • Self test (438)
((pIdx)->idxType==2)Description
TRUEevaluated 739 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 93 times by 1 test
Evaluated by:
  • Self test (438)
93-739
1843 for(i=n=0; i<nPk; i++){
i<nPkDescription
TRUEevaluated 101 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 93 times by 1 test
Evaluated by:
  • Self test (438)
93-101
1844 if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ) n++;
executed 97 times by 1 test: n++;
Executed by:
  • Self test (438)
!hasColumn(pId...->aiColumn[i])Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-97
1845 }
executed 101 times by 1 test: end of block
Executed by:
  • Self test (438)
101
1846 if( n==0 ){
n==0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 89 times by 1 test
Evaluated by:
  • Self test (438)
4-89
1847 /* This index is a superset of the primary key */-
1848 pIdx->nColumn = pIdx->nKeyCol;-
1849 continue;
executed 4 times by 1 test: continue;
Executed by:
  • Self test (438)
4
1850 }-
1851 if( resizeIndexObject(db, pIdx, pIdx->nKeyCol+n) ) return;
never executed: return;
resizeIndexObj...dx->nKeyCol+n)Description
TRUEnever evaluated
FALSEevaluated 89 times by 1 test
Evaluated by:
  • Self test (438)
0-89
1852 for(i=0, j=pIdx->nKeyCol; i<nPk; i++){
i<nPkDescription
TRUEevaluated 97 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 89 times by 1 test
Evaluated by:
  • Self test (438)
89-97
1853 if( !hasColumn(pIdx->aiColumn, pIdx->nKeyCol, pPk->aiColumn[i]) ){
!hasColumn(pId...->aiColumn[i])Description
TRUEevaluated 97 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-97
1854 pIdx->aiColumn[j] = pPk->aiColumn[i];-
1855 pIdx->azColl[j] = pPk->azColl[i];-
1856 j++;-
1857 }
executed 97 times by 1 test: end of block
Executed by:
  • Self test (438)
97
1858 }
executed 97 times by 1 test: end of block
Executed by:
  • Self test (438)
97
1859 assert( pIdx->nColumn>=pIdx->nKeyCol+n );-
1860 assert( pIdx->nColumn>=j );-
1861 }
executed 89 times by 1 test: end of block
Executed by:
  • Self test (438)
89
1862-
1863 /* Add all table columns to the PRIMARY KEY index-
1864 */-
1865 if( nPk<pTab->nCol ){
nPk<pTab->nColDescription
TRUEevaluated 628 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 111 times by 1 test
Evaluated by:
  • Self test (438)
111-628
1866 if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
never executed: return;
resizeIndexObj...k, pTab->nCol)Description
TRUEnever evaluated
FALSEevaluated 628 times by 1 test
Evaluated by:
  • Self test (438)
0-628
1867 for(i=0, j=nPk; i<pTab->nCol; i++){
i<pTab->nColDescription
TRUEevaluated 2092 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 628 times by 1 test
Evaluated by:
  • Self test (438)
628-2092
1868 if( !hasColumn(pPk->aiColumn, j, i) ){
!hasColumn(pPk...iColumn, j, i)Description
TRUEevaluated 1317 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 775 times by 1 test
Evaluated by:
  • Self test (438)
775-1317
1869 assert( j<pPk->nColumn );-
1870 pPk->aiColumn[j] = i;-
1871 pPk->azColl[j] = sqlite3StrBINARY;-
1872 j++;-
1873 }
executed 1317 times by 1 test: end of block
Executed by:
  • Self test (438)
1317
1874 }
executed 2092 times by 1 test: end of block
Executed by:
  • Self test (438)
2092
1875 assert( pPk->nColumn==j );-
1876 assert( pTab->nCol==j );-
1877 }else{
executed 628 times by 1 test: end of block
Executed by:
  • Self test (438)
628
1878 pPk->nColumn = pTab->nCol;-
1879 }
executed 111 times by 1 test: end of block
Executed by:
  • Self test (438)
111
1880 recomputeColumnsNotIndexed(pPk);-
1881}
executed 739 times by 1 test: end of block
Executed by:
  • Self test (438)
739
1882-
1883/*-
1884** This routine is called to report the final ")" that terminates-
1885** a CREATE TABLE statement.-
1886**-
1887** The table structure that other action routines have been building-
1888** is added to the internal hash tables, assuming no errors have-
1889** occurred.-
1890**-
1891** An entry for the table is made in the master table on disk, unless-
1892** this is a temporary table or db->init.busy==1. When db->init.busy==1-
1893** it means we are reading the sqlite_master table because we just-
1894** connected to the database or because the sqlite_master table has-
1895** recently changed, so the entry for this table already exists in-
1896** the sqlite_master table. We do not want to create it again.-
1897**-
1898** If the pSelect argument is not NULL, it means that this routine-
1899** was called to create a table generated from a -
1900** "CREATE TABLE ... AS SELECT ..." statement. The column names of-
1901** the new table will match the result set of the SELECT.-
1902*/-
1903void sqlite3EndTable(-
1904 Parse *pParse, /* Parse context */-
1905 Token *pCons, /* The ',' token after the last column defn. */-
1906 Token *pEnd, /* The ')' before options in the CREATE TABLE */-
1907 u8 tabOpts, /* Extra table options. Usually 0. */-
1908 Select *pSelect /* Select from a "CREATE ... AS SELECT" */-
1909){-
1910 Table *p; /* The new table */-
1911 sqlite3 *db = pParse->db; /* The database connection */-
1912 int iDb; /* Database in which the table lives */-
1913 Index *pIdx; /* An implied index of the table */-
1914-
1915 if( pEnd==0 && pSelect==0 ){
pEnd==0Description
TRUEevaluated 131 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 101789 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pSelect==0Description
TRUEnever evaluated
FALSEevaluated 131 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
0-101789
1916 return;
never executed: return;
0
1917 }-
1918 assert( !db->mallocFailed );-
1919 p = pParse->pNewTable;-
1920 if( p==0 ) return;
executed 22 times by 1 test: return;
Executed by:
  • Self test (438)
p==0Description
TRUEevaluated 22 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 101898 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
22-101898
1921-
1922 /* If the db->init.busy is 1 it means we are reading the SQL off the-
1923 ** "sqlite_master" or "sqlite_temp_master" table on the disk.-
1924 ** So do not write to the disk again. Extract the root page number-
1925 ** for the table from the db->init.newTnum field. (The page number-
1926 ** should have been put there by the sqliteOpenCb routine.)-
1927 **-
1928 ** If the root page number is 1, that means this is the sqlite_master-
1929 ** table itself. So mark it read-only.-
1930 */-
1931 if( db->init.busy ){
db->init.busyDescription
TRUEevaluated 79301 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 22597 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
22597-79301
1932 if( pSelect ){
pSelectDescription
TRUEnever evaluated
FALSEevaluated 79301 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
0-79301
1933 sqlite3ErrorMsg(pParse, "");-
1934 return;
never executed: return;
0
1935 }-
1936 p->tnum = db->init.newTnum;-
1937 if( p->tnum==1 ) p->tabFlags |= TF_Readonly;
executed 40421 times by 436 tests: p->tabFlags |= 0x0001;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
p->tnum==1Description
TRUEevaluated 40421 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 38880 times by 434 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
38880-40421
1938 }
executed 79301 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
79301
1939-
1940 /* Special processing for WITHOUT ROWID Tables */-
1941 if( tabOpts & TF_WithoutRowid ){
tabOpts & 0x0020Description
TRUEevaluated 774 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 101124 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
774-101124
1942 if( (p->tabFlags & TF_Autoincrement) ){
(p->tabFlags & 0x0008)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 772 times by 1 test
Evaluated by:
  • Self test (438)
2-772
1943 sqlite3ErrorMsg(pParse,-
1944 "AUTOINCREMENT not allowed on WITHOUT ROWID tables");-
1945 return;
executed 2 times by 1 test: return;
Executed by:
  • Self test (438)
2
1946 }-
1947 if( (p->tabFlags & TF_HasPrimaryKey)==0 ){
(p->tabFlags & 0x0004)==0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 768 times by 1 test
Evaluated by:
  • Self test (438)
4-768
1948 sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName);-
1949 }else{
executed 4 times by 1 test: end of block
Executed by:
  • Self test (438)
4
1950 p->tabFlags |= TF_WithoutRowid | TF_NoVisibleRowid;-
1951 convertToWithoutRowidTable(pParse, p);-
1952 }
executed 768 times by 1 test: end of block
Executed by:
  • Self test (438)
768
1953 }-
1954-
1955 iDb = sqlite3SchemaToIndex(db, p->pSchema);-
1956-
1957#ifndef SQLITE_OMIT_CHECK-
1958 /* Resolve names in all CHECK constraint expressions.-
1959 */-
1960 if( p->pCheck ){
p->pCheckDescription
TRUEevaluated 311 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 101585 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
311-101585
1961 sqlite3ResolveSelfReference(pParse, p, NC_IsCheck, 0, p->pCheck);-
1962 }
executed 311 times by 1 test: end of block
Executed by:
  • Self test (438)
311
1963#endif /* !defined(SQLITE_OMIT_CHECK) */-
1964-
1965 /* Estimate the average row size for the table and for all implied indices */-
1966 estimateTableWidth(p);-
1967 for(pIdx=p->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 6671 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 101896 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
6671-101896
1968 estimateIndexWidth(pIdx);-
1969 }
executed 6671 times by 376 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6671
1970-
1971 /* If not initializing, then create a record for the new table-
1972 ** in the SQLITE_MASTER table of the database.-
1973 **-
1974 ** If this is a TEMPORARY table, write the entry into the auxiliary-
1975 ** file instead of into the main database file.-
1976 */-
1977 if( !db->init.busy ){
!db->init.busyDescription
TRUEevaluated 22595 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
FALSEevaluated 79301 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
22595-79301
1978 int n;-
1979 Vdbe *v;-
1980 char *zType; /* "view" or "table" */-
1981 char *zType2; /* "VIEW" or "TABLE" */-
1982 char *zStmt; /* Text of the CREATE TABLE or CREATE VIEW statement */-
1983-
1984 v = sqlite3GetVdbe(pParse);-
1985 if( NEVER(v==0) ) return;
never executed: return;
(v==0)Description
TRUEnever evaluated
FALSEevaluated 22595 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
0-22595
1986-
1987 sqlite3VdbeAddOp1(v, OP_Close, 0);-
1988-
1989 /* -
1990 ** Initialize zType for the new view or table.-
1991 */-
1992 if( p->pSelect==0 ){
p->pSelect==0Description
TRUEevaluated 22040 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
FALSEevaluated 555 times by 6 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
555-22040
1993 /* A regular table */-
1994 zType = "table";-
1995 zType2 = "TABLE";-
1996#ifndef SQLITE_OMIT_VIEW-
1997 }else{
executed 22040 times by 30 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
22040
1998 /* A view */-
1999 zType = "view";-
2000 zType2 = "VIEW";-
2001#endif-
2002 }
executed 555 times by 6 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
555
2003-
2004 /* If this is a CREATE TABLE xx AS SELECT ..., execute the SELECT-
2005 ** statement to populate the new table. The root-page number for the-
2006 ** new table is in register pParse->regRoot.-
2007 **-
2008 ** Once the SELECT has been coded by sqlite3Select(), it is in a-
2009 ** suitable state to query for the column names and types to be used-
2010 ** by the new table.-
2011 **-
2012 ** A shared-cache write-lock is not required to write to the new table,-
2013 ** as a schema-lock must have already been obtained to create it. Since-
2014 ** a schema-lock excludes all other database users, the write-lock would-
2015 ** be redundant.-
2016 */-
2017 if( pSelect ){
pSelectDescription
TRUEevaluated 127 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 22468 times by 27 tests
Evaluated by:
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • ...
127-22468
2018 SelectDest dest; /* Where the SELECT should store results */-
2019 int regYield; /* Register holding co-routine entry-point */-
2020 int addrTop; /* Top of the co-routine */-
2021 int regRec; /* A record to be insert into the new table */-
2022 int regRowid; /* Rowid of the next row to insert */-
2023 int addrInsLoop; /* Top of the loop for inserting rows */-
2024 Table *pSelTab; /* A table that describes the SELECT results */-
2025-
2026 regYield = ++pParse->nMem;-
2027 regRec = ++pParse->nMem;-
2028 regRowid = ++pParse->nMem;-
2029 assert(pParse->nTab==1);-
2030 sqlite3MayAbort(pParse);-
2031 sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb);-
2032 sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG);-
2033 pParse->nTab = 2;-
2034 addrTop = sqlite3VdbeCurrentAddr(v) + 1;-
2035 sqlite3VdbeAddOp3(v, OP_InitCoroutine, regYield, 0, addrTop);-
2036 if( pParse->nErr ) return;
executed 1 time by 1 test: return;
Executed by:
  • Self test (438)
pParse->nErrDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 126 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
1-126
2037 pSelTab = sqlite3ResultSetOfSelect(pParse, pSelect);-
2038 if( pSelTab==0 ) return;
executed 4 times by 1 test: return;
Executed by:
  • Self test (438)
pSelTab==0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 122 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
4-122
2039 assert( p->aCol==0 );-
2040 p->nCol = pSelTab->nCol;-
2041 p->aCol = pSelTab->aCol;-
2042 pSelTab->nCol = 0;-
2043 pSelTab->aCol = 0;-
2044 sqlite3DeleteTable(db, pSelTab);-
2045 sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);-
2046 sqlite3Select(pParse, pSelect, &dest);-
2047 if( pParse->nErr ) return;
executed 1 time by 1 test: return;
Executed by:
  • Self test (438)
pParse->nErrDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 121 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
1-121
2048 sqlite3VdbeEndCoroutine(v, regYield);-
2049 sqlite3VdbeJumpHere(v, addrTop - 1);-
2050 addrInsLoop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm);-
2051 VdbeCoverage(v);-
2052 sqlite3VdbeAddOp3(v, OP_MakeRecord, dest.iSdst, dest.nSdst, regRec);-
2053 sqlite3TableAffinity(v, p, 0);-
2054 sqlite3VdbeAddOp2(v, OP_NewRowid, 1, regRowid);-
2055 sqlite3VdbeAddOp3(v, OP_Insert, 1, regRec, regRowid);-
2056 sqlite3VdbeGoto(v, addrInsLoop);-
2057 sqlite3VdbeJumpHere(v, addrInsLoop);-
2058 sqlite3VdbeAddOp1(v, OP_Close, 1);-
2059 }
executed 121 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
121
2060-
2061 /* Compute the complete text of the CREATE statement */-
2062 if( pSelect ){
pSelectDescription
TRUEevaluated 121 times by 4 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
FALSEevaluated 22468 times by 27 tests
Evaluated by:
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • ...
121-22468
2063 zStmt = createTableStmt(db, p);-
2064 }else{
executed 121 times by 4 tests: end of block
Executed by:
  • Self test
  • Self test (438)
  • Self test (57)
  • Self test (58)
121
2065 Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd;
tabOptsDescription
TRUEevaluated 344 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 22124 times by 27 tests
Evaluated by:
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • ...
344-22124
2066 n = (int)(pEnd2->z - pParse->sNameToken.z);-
2067 if( pEnd2->z[0]!=';' ) n += pEnd2->n;
executed 22182 times by 27 tests: n += pEnd2->n;
Executed by:
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • ...
pEnd2->z[0]!=';'Description
TRUEevaluated 22182 times by 27 tests
Evaluated by:
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • ...
FALSEevaluated 286 times by 1 test
Evaluated by:
  • Self test (438)
286-22182
2068 zStmt = sqlite3MPrintf(db, -
2069 "CREATE %s %.*s", zType2, n, pParse->sNameToken.z-
2070 );-
2071 }
executed 22468 times by 27 tests: end of block
Executed by:
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • ...
22468
2072-
2073 /* A slot for the record has already been allocated in the -
2074 ** SQLITE_MASTER table. We just need to update that slot with all-
2075 ** the information we've collected.-
2076 */-
2077 sqlite3NestedParse(pParse,-
2078 "UPDATE %Q.%s "-
2079 "SET type='%s', name=%Q, tbl_name=%Q, rootpage=#%d, sql=%Q "-
2080 "WHERE rowid=#%d",-
2081 db->aDb[iDb].zDbSName, MASTER_NAME,-
2082 zType,-
2083 p->zName,-
2084 p->zName,-
2085 pParse->regRoot,-
2086 zStmt,-
2087 pParse->regRowid-
2088 );-
2089 sqlite3DbFree(db, zStmt);-
2090 sqlite3ChangeCookie(pParse, iDb);-
2091-
2092#ifndef SQLITE_OMIT_AUTOINCREMENT-
2093 /* Check to see if we need to create an sqlite_sequence table for-
2094 ** keeping track of autoincrement keys.-
2095 */-
2096 if( (p->tabFlags & TF_Autoincrement)!=0 ){
(p->tabFlags & 0x0008)!=0Description
TRUEevaluated 75 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 22514 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
75-22514
2097 Db *pDb = &db->aDb[iDb];-
2098 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
2099 if( pDb->pSchema->pSeqTab==0 ){
pDb->pSchema->pSeqTab==0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test (438)
30-45
2100 sqlite3NestedParse(pParse,-
2101 "CREATE TABLE %Q.sqlite_sequence(name,seq)",-
2102 pDb->zDbSName-
2103 );-
2104 }
executed 30 times by 1 test: end of block
Executed by:
  • Self test (438)
30
2105 }
executed 75 times by 1 test: end of block
Executed by:
  • Self test (438)
75
2106#endif-
2107-
2108 /* Reparse everything to update our internal data structures */-
2109 sqlite3VdbeAddParseSchemaOp(v, iDb,-
2110 sqlite3MPrintf(db, "tbl_name='%q' AND type!='trigger'", p->zName));-
2111 }
executed 22589 times by 30 tests: end of block
Executed by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
22589
2112-
2113-
2114 /* Add the table to the in-memory representation of the database.-
2115 */-
2116 if( db->init.busy ){
db->init.busyDescription
TRUEevaluated 79301 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 22589 times by 30 tests
Evaluated by:
  • Self test
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (30)
  • Self test (32)
  • Self test (33)
  • Self test (34)
  • Self test (39)
  • Self test (438)
  • Self test (47)
  • Self test (48)
  • Self test (57)
  • Self test (58)
  • Self test (72)
  • Self test (73)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • ...
22589-79301
2117 Table *pOld;-
2118 Schema *pSchema = p->pSchema;-
2119 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
2120 pOld = sqlite3HashInsert(&pSchema->tblHash, p->zName, p);-
2121 if( pOld ){
pOldDescription
TRUEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 79274 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
27-79274
2122 assert( p==pOld ); /* Malloc must have failed inside HashInsert() */-
2123 sqlite3OomFault(db);-
2124 return;
executed 27 times by 1 test: return;
Executed by:
  • Self test (438)
27
2125 }-
2126 pParse->pNewTable = 0;-
2127 db->mDbFlags |= DBFLAG_SchemaChange;-
2128-
2129#ifndef SQLITE_OMIT_ALTERTABLE-
2130 if( !p->pSelect ){
!p->pSelectDescription
TRUEevaluated 75429 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 3845 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
3845-75429
2131 const char *zName = (const char *)pParse->sNameToken.z;-
2132 int nName;-
2133 assert( !pSelect && pCons && pEnd );-
2134 if( pCons->z==0 ){
pCons->z==0Description
TRUEevaluated 74367 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1062 times by 3 tests
Evaluated by:
  • Self test (32)
  • Self test (33)
  • Self test (438)
1062-74367
2135 pCons = pEnd;-
2136 }
executed 74367 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
74367
2137 nName = (int)((const char *)pCons->z - zName);-
2138 p->addColOffset = 13 + sqlite3Utf8CharLen(zName, nName);-
2139 }
executed 75429 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
75429
2140#endif-
2141 }
executed 79274 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
79274
2142}
executed 101863 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
101863
2143-
2144#ifndef SQLITE_OMIT_VIEW-
2145/*-
2146** The parser calls this routine in order to create a new VIEW-
2147*/-
2148void sqlite3CreateView(-
2149 Parse *pParse, /* The parsing context */-
2150 Token *pBegin, /* The CREATE token that begins the statement */-
2151 Token *pName1, /* The token that holds the name of the view */-
2152 Token *pName2, /* The token that holds the name of the view */-
2153 ExprList *pCNames, /* Optional list of view column names */-
2154 Select *pSelect, /* A SELECT statement that will become the new view */-
2155 int isTemp, /* TRUE for a TEMPORARY view */-
2156 int noErr /* Suppress error messages if VIEW already exists */-
2157){-
2158 Table *p;-
2159 int n;-
2160 const char *z;-
2161 Token sEnd;-
2162 DbFixer sFix;-
2163 Token *pName = 0;-
2164 int iDb;-
2165 sqlite3 *db = pParse->db;-
2166-
2167 if( pParse->nVar>0 ){
pParse->nVar>0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4417 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
3-4417
2168 sqlite3ErrorMsg(pParse, "parameters are not allowed in views");-
2169 goto create_view_fail;
executed 3 times by 1 test: goto create_view_fail;
Executed by:
  • Self test (438)
3
2170 }-
2171 sqlite3StartTable(pParse, pName1, pName2, isTemp, 1, 0, noErr);-
2172 p = pParse->pNewTable;-
2173 if( p==0 || pParse->nErr ) goto create_view_fail;
executed 14 times by 1 test: goto create_view_fail;
Executed by:
  • Self test (438)
p==0Description
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4403 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
pParse->nErrDescription
TRUEnever evaluated
FALSEevaluated 4403 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
0-4403
2174 sqlite3TwoPartName(pParse, pName1, pName2, &pName);-
2175 iDb = sqlite3SchemaToIndex(db, p->pSchema);-
2176 sqlite3FixInit(&sFix, pParse, iDb, "view", pName);-
2177 if( sqlite3FixSelect(&sFix, pSelect) ) goto create_view_fail;
executed 3 times by 1 test: goto create_view_fail;
Executed by:
  • Self test (438)
sqlite3FixSele...sFix, pSelect)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4400 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
3-4400
2178-
2179 /* Make a copy of the entire SELECT statement that defines the view.-
2180 ** This will force all the Expr.token.z values to be dynamically-
2181 ** allocated rather than point to the input string - which means that-
2182 ** they will persist after the current sqlite3_exec() call returns.-
2183 */-
2184 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4292 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
108-4292
2185 p->pSelect = pSelect;-
2186 pSelect = 0;-
2187 }else{
executed 108 times by 1 test: end of block
Executed by:
  • Self test (438)
108
2188 p->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);-
2189 }
executed 4292 times by 7 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
4292
2190 p->pCheck = sqlite3ExprListDup(db, pCNames, EXPRDUP_REDUCE);-
2191 if( db->mallocFailed ) goto create_view_fail;
never executed: goto create_view_fail;
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 4400 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
0-4400
2192-
2193 /* Locate the end of the CREATE VIEW statement. Make sEnd point to-
2194 ** the end.-
2195 */-
2196 sEnd = pParse->sLastToken;-
2197 assert( sEnd.z[0]!=0 || sEnd.n==0 );-
2198 if( sEnd.z[0]!=';' ){
sEnd.z[0]!=';'Description
TRUEevaluated 3990 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
FALSEevaluated 410 times by 1 test
Evaluated by:
  • Self test (438)
410-3990
2199 sEnd.z += sEnd.n;-
2200 }
executed 3990 times by 7 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
3990
2201 sEnd.n = 0;-
2202 n = (int)(sEnd.z - pBegin->z);-
2203 assert( n>0 );-
2204 z = pBegin->z;-
2205 while( sqlite3Isspace(z[n-1]) ){ n--; }
executed 38 times by 6 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
(sqlite3CtypeM...z[n-1])]&0x01)Description
TRUEevaluated 38 times by 6 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
FALSEevaluated 4400 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
38-4400
2206 sEnd.z = &z[n-1];-
2207 sEnd.n = 1;-
2208-
2209 /* Use sqlite3EndTable() to add the view to the SQLITE_MASTER table */-
2210 sqlite3EndTable(pParse, 0, &sEnd, 0, 0);-
2211-
2212create_view_fail:
code before this statement executed 4400 times by 7 tests: create_view_fail:
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
4400
2213 sqlite3SelectDelete(db, pSelect);-
2214 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 108 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4312 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
108-4312
2215 sqlite3RenameExprlistUnmap(pParse, pCNames);-
2216 }
executed 108 times by 1 test: end of block
Executed by:
  • Self test (438)
108
2217 sqlite3ExprListDelete(db, pCNames);-
2218 return;
executed 4420 times by 7 tests: return;
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
4420
2219}-
2220#endif /* SQLITE_OMIT_VIEW */-
2221-
2222#if !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE)-
2223/*-
2224** The Table structure pTable is really a VIEW. Fill in the names of-
2225** the columns of the view in the pTable structure. Return the number-
2226** of errors. If an error is seen leave an error message in pParse->zErrMsg.-
2227*/-
2228int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){-
2229 Table *pSelTab; /* A fake table from which we get the result set */-
2230 Select *pSel; /* Copy of the SELECT that implements the view */-
2231 int nErr = 0; /* Number of errors encountered */-
2232 int n; /* Temporarily holds the number of cursors assigned */-
2233 sqlite3 *db = pParse->db; /* Database connection for malloc errors */-
2234#ifndef SQLITE_OMIT_VIRTUALTABLE-
2235 int rc;-
2236#endif-
2237#ifndef SQLITE_OMIT_AUTHORIZATION-
2238 sqlite3_xauth xAuth; /* Saved xAuth pointer */-
2239#endif-
2240-
2241 assert( pTable );-
2242-
2243#ifndef SQLITE_OMIT_VIRTUALTABLE-
2244 db->nSchemaLock++;-
2245 rc = sqlite3VtabCallConnect(pParse, pTable);-
2246 db->nSchemaLock--;-
2247 if( rc ){
rcDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 468631 times by 407 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
12-468631
2248 return 1;
executed 12 times by 1 test: return 1;
Executed by:
  • Self test (438)
12
2249 }-
2250 if( IsVirtual(pTable) ) return 0;
executed 12705 times by 1 test: return 0;
Executed by:
  • Self test (438)
((pTable)->nModuleArg)Description
TRUEevaluated 12705 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 455926 times by 407 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
12705-455926
2251#endif-
2252-
2253#ifndef SQLITE_OMIT_VIEW-
2254 /* A positive nCol means the columns names for this view are-
2255 ** already known.-
2256 */-
2257 if( pTable->nCol>0 ) return 0;
executed 455053 times by 407 tests: return 0;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
pTable->nCol>0Description
TRUEevaluated 455053 times by 407 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
FALSEevaluated 873 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
873-455053
2258-
2259 /* A negative nCol is a special marker meaning that we are currently-
2260 ** trying to compute the column names. If we enter this routine with-
2261 ** a negative nCol, it means two or more views form a loop, like this:-
2262 **-
2263 ** CREATE VIEW one AS SELECT * FROM two;-
2264 ** CREATE VIEW two AS SELECT * FROM one;-
2265 **-
2266 ** Actually, the error above is now caught prior to reaching this point.-
2267 ** But the following test is still important as it does come up-
2268 ** in the following:-
2269 ** -
2270 ** CREATE TABLE main.ex1(a);-
2271 ** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;-
2272 ** SELECT * FROM temp.ex1;-
2273 */-
2274 if( pTable->nCol<0 ){
pTable->nCol<0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 870 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
3-870
2275 sqlite3ErrorMsg(pParse, "view %s is circularly defined", pTable->zName);-
2276 return 1;
executed 3 times by 1 test: return 1;
Executed by:
  • Self test (438)
3
2277 }-
2278 assert( pTable->nCol>=0 );-
2279-
2280 /* If we get this far, it means we need to compute the table names.-
2281 ** Note that the call to sqlite3ResultSetOfSelect() will expand any-
2282 ** "*" elements in the results set of the view and will assign cursors-
2283 ** to the elements of the FROM clause. But we do not want these changes-
2284 ** to be permanent. So the computation is done on a copy of the SELECT-
2285 ** statement that defines the view.-
2286 */-
2287 assert( pTable->pSelect );-
2288 pSel = sqlite3SelectDup(db, pTable->pSelect, 0);-
2289 if( pSel ){
pSelDescription
TRUEevaluated 870 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEnever evaluated
0-870
2290#ifndef SQLITE_OMIT_ALTERTABLE-
2291 u8 eParseMode = pParse->eParseMode;-
2292 pParse->eParseMode = PARSE_MODE_NORMAL;-
2293#endif-
2294 n = pParse->nTab;-
2295 sqlite3SrcListAssignCursors(pParse, pSel->pSrc);-
2296 pTable->nCol = -1;-
2297 db->lookaside.bDisable++;-
2298#ifndef SQLITE_OMIT_AUTHORIZATION-
2299 xAuth = db->xAuth;-
2300 db->xAuth = 0;-
2301 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);-
2302 db->xAuth = xAuth;-
2303#else-
2304 pSelTab = sqlite3ResultSetOfSelect(pParse, pSel);-
2305#endif-
2306 pParse->nTab = n;-
2307 if( pTable->pCheck ){
pTable->pCheckDescription
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 859 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
11-859
2308 /* CREATE VIEW name(arglist) AS ...-
2309 ** The names of the columns in the table are taken from-
2310 ** arglist which is stored in pTable->pCheck. The pCheck field-
2311 ** normally holds CHECK constraints on an ordinary table, but for-
2312 ** a VIEW it holds the list of column names.-
2313 */-
2314 sqlite3ColumnsFromExprList(pParse, pTable->pCheck, -
2315 &pTable->nCol, &pTable->aCol);-
2316 if( db->mallocFailed==0
db->mallocFailed==0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-11
2317 && pParse->nErr==0
pParse->nErr==0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-10
2318 && pTable->nCol==pSel->pEList->nExpr
pTable->nCol==...>pEList->nExprDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-8
2319 ){-
2320 sqlite3SelectAddColumnTypeAndCollation(pParse, pTable, pSel);-
2321 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test (438)
8
2322 }else if( pSelTab ){
executed 11 times by 1 test: end of block
Executed by:
  • Self test (438)
pSelTabDescription
TRUEevaluated 848 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
11-848
2323 /* CREATE VIEW name AS... without an argument list. Construct-
2324 ** the column names from the SELECT statement that defines the view.-
2325 */-
2326 assert( pTable->aCol==0 );-
2327 pTable->nCol = pSelTab->nCol;-
2328 pTable->aCol = pSelTab->aCol;-
2329 pSelTab->nCol = 0;-
2330 pSelTab->aCol = 0;-
2331 assert( sqlite3SchemaMutexHeld(db, 0, pTable->pSchema) );-
2332 }else{
executed 848 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
848
2333 pTable->nCol = 0;-
2334 nErr++;-
2335 }
executed 11 times by 1 test: end of block
Executed by:
  • Self test (438)
11
2336 sqlite3DeleteTable(db, pSelTab);-
2337 sqlite3SelectDelete(db, pSel);-
2338 db->lookaside.bDisable--;-
2339#ifndef SQLITE_OMIT_ALTERTABLE-
2340 pParse->eParseMode = eParseMode;-
2341#endif-
2342 } else {
executed 870 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
870
2343 nErr++;-
2344 }
never executed: end of block
0
2345 pTable->pSchema->schemaFlags |= DB_UnresetViews;-
2346 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 870 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
0-870
2347 sqlite3DeleteColumnNames(db, pTable);-
2348 pTable->aCol = 0;-
2349 pTable->nCol = 0;-
2350 }
never executed: end of block
0
2351#endif /* SQLITE_OMIT_VIEW */-
2352 return nErr;
executed 870 times by 2 tests: return nErr;
Executed by:
  • Self test (438)
  • Self test (47)
870
2353}-
2354#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */-
2355-
2356#ifndef SQLITE_OMIT_VIEW-
2357/*-
2358** Clear the column names from every VIEW in database idx.-
2359*/-
2360static void sqliteViewResetAll(sqlite3 *db, int idx){-
2361 HashElem *i;-
2362 assert( sqlite3SchemaMutexHeld(db, idx, 0) );-
2363 if( !DbHasProperty(db, idx, DB_UnresetViews) ) return;
executed 4871 times by 4 tests: return;
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
!(((db)->aDb[i...2))==(0x0002))Description
TRUEevaluated 4871 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 40 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
40-4871
2364 for(i=sqliteHashFirst(&db->aDb[idx].pSchema->tblHash); i;i=sqliteHashNext(i)){
iDescription
TRUEevaluated 301 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 40 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
40-301
2365 Table *pTab = sqliteHashData(i);-
2366 if( pTab->pSelect ){
pTab->pSelectDescription
TRUEevaluated 140 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 161 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
140-161
2367 sqlite3DeleteColumnNames(db, pTab);-
2368 pTab->aCol = 0;-
2369 pTab->nCol = 0;-
2370 }
executed 140 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
140
2371 }
executed 301 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
301
2372 DbClearProperty(db, idx, DB_UnresetViews);-
2373}
executed 40 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
40
2374#else-
2375# define sqliteViewResetAll(A,B)-
2376#endif /* SQLITE_OMIT_VIEW */-
2377-
2378/*-
2379** This function is called by the VDBE to adjust the internal schema-
2380** used by SQLite when the btree layer moves a table root page. The-
2381** root-page of a table or index in database iDb has changed from iFrom-
2382** to iTo.-
2383**-
2384** Ticket #1728: The symbol table might still contain information-
2385** on tables and/or indices that are the process of being deleted.-
2386** If you are unlucky, one of those deleted indices or tables might-
2387** have the same rootpage number as the real table or index that is-
2388** being moved. So we cannot stop searching after the first match -
2389** because the first match might be for one of the deleted indices-
2390** or tables and not the table/index that is actually being moved.-
2391** We must continue looping until all tables and indices with-
2392** rootpage==iFrom have been converted to have a rootpage of iTo-
2393** in order to be certain that we got the right one.-
2394*/-
2395#ifndef SQLITE_OMIT_AUTOVACUUM-
2396void sqlite3RootPageMoved(sqlite3 *db, int iDb, int iFrom, int iTo){-
2397 HashElem *pElem;-
2398 Hash *pHash;-
2399 Db *pDb;-
2400-
2401 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
2402 pDb = &db->aDb[iDb];-
2403 pHash = &pDb->pSchema->tblHash;-
2404 for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){
pElemDescription
TRUEevaluated 105396 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 368 times by 1 test
Evaluated by:
  • Self test (438)
368-105396
2405 Table *pTab = sqliteHashData(pElem);-
2406 if( pTab->tnum==iFrom ){
pTab->tnum==iFromDescription
TRUEevaluated 346 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 105050 times by 1 test
Evaluated by:
  • Self test (438)
346-105050
2407 pTab->tnum = iTo;-
2408 }
executed 346 times by 1 test: end of block
Executed by:
  • Self test (438)
346
2409 }
executed 105396 times by 1 test: end of block
Executed by:
  • Self test (438)
105396
2410 pHash = &pDb->pSchema->idxHash;-
2411 for(pElem=sqliteHashFirst(pHash); pElem; pElem=sqliteHashNext(pElem)){
pElemDescription
TRUEevaluated 132 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 368 times by 1 test
Evaluated by:
  • Self test (438)
132-368
2412 Index *pIdx = sqliteHashData(pElem);-
2413 if( pIdx->tnum==iFrom ){
pIdx->tnum==iFromDescription
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 107 times by 1 test
Evaluated by:
  • Self test (438)
25-107
2414 pIdx->tnum = iTo;-
2415 }
executed 25 times by 1 test: end of block
Executed by:
  • Self test (438)
25
2416 }
executed 132 times by 1 test: end of block
Executed by:
  • Self test (438)
132
2417}
executed 368 times by 1 test: end of block
Executed by:
  • Self test (438)
368
2418#endif-
2419-
2420/*-
2421** Write code to erase the table with root-page iTable from database iDb.-
2422** Also write code to modify the sqlite_master table and internal schema-
2423** if a root-page of another table is moved by the btree-layer whilst-
2424** erasing iTable (this can happen with an auto-vacuum database).-
2425*/ -
2426static void destroyRootPage(Parse *pParse, int iTable, int iDb){-
2427 Vdbe *v = sqlite3GetVdbe(pParse);-
2428 int r1 = sqlite3GetTempReg(pParse);-
2429 assert( iTable>1 );-
2430 sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb);-
2431 sqlite3MayAbort(pParse);-
2432#ifndef SQLITE_OMIT_AUTOVACUUM-
2433 /* OP_Destroy stores an in integer r1. If this integer-
2434 ** is non-zero, then it is the root page number of a table moved to-
2435 ** location iTable. The following code modifies the sqlite_master table to-
2436 ** reflect this.-
2437 **-
2438 ** The "#NNN" in the SQL is a special constant that means whatever value-
2439 ** is in register NNN. See grammar rules associated with the TK_REGISTER-
2440 ** token for additional information.-
2441 */-
2442 sqlite3NestedParse(pParse, -
2443 "UPDATE %Q.%s SET rootpage=%d WHERE #%d AND rootpage=#%d",-
2444 pParse->db->aDb[iDb].zDbSName, MASTER_NAME, iTable, r1, r1);-
2445#endif-
2446 sqlite3ReleaseTempReg(pParse, r1);-
2447}
executed 5735 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5735
2448-
2449/*-
2450** Write VDBE code to erase table pTab and all associated indices on disk.-
2451** Code to update the sqlite_master tables and internal schema definitions-
2452** in case a root-page belonging to another table is moved by the btree layer-
2453** is also added (this can happen with an auto-vacuum database).-
2454*/-
2455static void destroyTable(Parse *pParse, Table *pTab){-
2456 /* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM-
2457 ** is not defined), then it is important to call OP_Destroy on the-
2458 ** table and index root-pages in order, starting with the numerically -
2459 ** largest root-page number. This guarantees that none of the root-pages-
2460 ** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the-
2461 ** following were coded:-
2462 **-
2463 ** OP_Destroy 4 0-
2464 ** ...-
2465 ** OP_Destroy 5 0-
2466 **-
2467 ** and root page 5 happened to be the largest root-page number in the-
2468 ** database, then root page 5 would be moved to page 4 by the -
2469 ** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit-
2470 ** a free-list page.-
2471 */-
2472 int iTab = pTab->tnum;-
2473 int iDestroyed = 0;-
2474-
2475 while( 1 ){-
2476 Index *pIdx;-
2477 int iLargest = 0;-
2478-
2479 if( iDestroyed==0 || iTab<iDestroyed ){
iDestroyed==0Description
TRUEevaluated 4761 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 5535 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
iTab<iDestroyedDescription
TRUEevaluated 749 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4786 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
749-5535
2480 iLargest = iTab;-
2481 }
executed 5510 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5510
2482 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 12673 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10296 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
10296-12673
2483 int iIdx = pIdx->tnum;-
2484 assert( pIdx->pSchema==pTab->pSchema );-
2485 if( (iDestroyed==0 || (iIdx<iDestroyed)) && iIdx>iLargest ){
iDestroyed==0Description
TRUEevaluated 924 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11749 times by 1 test
Evaluated by:
  • Self test (438)
(iIdx<iDestroyed)Description
TRUEevaluated 5064 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6685 times by 1 test
Evaluated by:
  • Self test (438)
iIdx>iLargestDescription
TRUEevaluated 778 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5210 times by 1 test
Evaluated by:
  • Self test (438)
778-11749
2486 iLargest = iIdx;-
2487 }
executed 778 times by 1 test: end of block
Executed by:
  • Self test (438)
778
2488 }
executed 12673 times by 1 test: end of block
Executed by:
  • Self test (438)
12673
2489 if( iLargest==0 ){
iLargest==0Description
TRUEevaluated 4761 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 5535 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4761-5535
2490 return;
executed 4761 times by 4 tests: return;
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4761
2491 }else{-
2492 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);-
2493 assert( iDb>=0 && iDb<pParse->db->nDb );-
2494 destroyRootPage(pParse, iLargest, iDb);-
2495 iDestroyed = iLargest;-
2496 }
executed 5535 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5535
2497 }-
2498}
never executed: end of block
0
2499-
2500/*-
2501** Remove entries from the sqlite_statN tables (for N in (1,2,3))-
2502** after a DROP INDEX or DROP TABLE command.-
2503*/-
2504static void sqlite3ClearStatTables(-
2505 Parse *pParse, /* The parsing context */-
2506 int iDb, /* The database number */-
2507 const char *zType, /* "idx" or "tbl" */-
2508 const char *zName /* Name of index or table */-
2509){-
2510 int i;-
2511 const char *zDbName = pParse->db->aDb[iDb].zDbSName;-
2512 for(i=1; i<=4; i++){
i<=4Description
TRUEevaluated 20096 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 5024 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5024-20096
2513 char zTab[24];-
2514 sqlite3_snprintf(sizeof(zTab),zTab,"sqlite_stat%d",i);-
2515 if( sqlite3FindTable(pParse->db, zTab, zDbName) ){
sqlite3FindTab...zTab, zDbName)Description
TRUEevaluated 48 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 20048 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
48-20048
2516 sqlite3NestedParse(pParse,-
2517 "DELETE FROM %Q.%s WHERE %s=%Q",-
2518 zDbName, zTab, zType, zName-
2519 );-
2520 }
executed 48 times by 1 test: end of block
Executed by:
  • Self test (438)
48
2521 }
executed 20096 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
20096
2522}
executed 5024 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5024
2523-
2524/*-
2525** Generate code to drop a table.-
2526*/-
2527void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){-
2528 Vdbe *v;-
2529 sqlite3 *db = pParse->db;-
2530 Trigger *pTrigger;-
2531 Db *pDb = &db->aDb[iDb];-
2532-
2533 v = sqlite3GetVdbe(pParse);-
2534 assert( v!=0 );-
2535 sqlite3BeginWriteOperation(pParse, 1, iDb);-
2536-
2537#ifndef SQLITE_OMIT_VIRTUALTABLE-
2538 if( IsVirtual(pTab) ){
((pTab)->nModuleArg)Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4848 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
63-4848
2539 sqlite3VdbeAddOp0(v, OP_VBegin);-
2540 }
executed 63 times by 1 test: end of block
Executed by:
  • Self test (438)
63
2541#endif-
2542-
2543 /* Drop all triggers associated with the table being dropped. Code-
2544 ** is generated to remove entries from sqlite_master and/or-
2545 ** sqlite_temp_master if required.-
2546 */-
2547 pTrigger = sqlite3TriggerList(pParse, pTab);-
2548 while( pTrigger ){
pTriggerDescription
TRUEevaluated 179 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4911 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
179-4911
2549 assert( pTrigger->pSchema==pTab->pSchema || -
2550 pTrigger->pSchema==db->aDb[1].pSchema );-
2551 sqlite3DropTriggerPtr(pParse, pTrigger);-
2552 pTrigger = pTrigger->pNext;-
2553 }
executed 179 times by 1 test: end of block
Executed by:
  • Self test (438)
179
2554-
2555#ifndef SQLITE_OMIT_AUTOINCREMENT-
2556 /* Remove any entries of the sqlite_sequence table associated with-
2557 ** the table being dropped. This is done before the table is dropped-
2558 ** at the btree level, in case the sqlite_sequence table needs to-
2559 ** move as a result of the drop (can happen in auto-vacuum mode).-
2560 */-
2561 if( pTab->tabFlags & TF_Autoincrement ){
pTab->tabFlags & 0x0008Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4901 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
10-4901
2562 sqlite3NestedParse(pParse,-
2563 "DELETE FROM %Q.sqlite_sequence WHERE name=%Q",-
2564 pDb->zDbSName, pTab->zName-
2565 );-
2566 }
executed 10 times by 1 test: end of block
Executed by:
  • Self test (438)
10
2567#endif-
2568-
2569 /* Drop all SQLITE_MASTER table and index entries that refer to the-
2570 ** table. The program name loops through the master table and deletes-
2571 ** every row that refers to a table of the same name as the one being-
2572 ** dropped. Triggers are handled separately because a trigger can be-
2573 ** created in the temp database that refers to a table in another-
2574 ** database.-
2575 */-
2576 sqlite3NestedParse(pParse, -
2577 "DELETE FROM %Q.%s WHERE tbl_name=%Q and type!='trigger'",-
2578 pDb->zDbSName, MASTER_NAME, pTab->zName);-
2579 if( !isView && !IsVirtual(pTab) ){
!isViewDescription
TRUEevaluated 4824 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 87 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
!((pTab)->nModuleArg)Description
TRUEevaluated 4761 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test (438)
63-4824
2580 destroyTable(pParse, pTab);-
2581 }
executed 4761 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4761
2582-
2583 /* Remove the table entry from SQLite's internal schema and modify-
2584 ** the schema cookie.-
2585 */-
2586 if( IsVirtual(pTab) ){
((pTab)->nModuleArg)Description
TRUEevaluated 63 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4848 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
63-4848
2587 sqlite3VdbeAddOp4(v, OP_VDestroy, iDb, 0, 0, pTab->zName, 0);-
2588 }
executed 63 times by 1 test: end of block
Executed by:
  • Self test (438)
63
2589 sqlite3VdbeAddOp4(v, OP_DropTable, iDb, 0, 0, pTab->zName, 0);-
2590 sqlite3ChangeCookie(pParse, iDb);-
2591 sqliteViewResetAll(db, iDb);-
2592}
executed 4911 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4911
2593-
2594/*-
2595** This routine is called to do the work of a DROP TABLE statement.-
2596** pName is the name of the table to be dropped.-
2597*/-
2598void sqlite3DropTable(Parse *pParse, SrcList *pName, int isView, int noErr){-
2599 Table *pTab;-
2600 Vdbe *v;-
2601 sqlite3 *db = pParse->db;-
2602 int iDb;-
2603-
2604 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5261 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
2-5261
2605 goto exit_drop_table;
executed 2 times by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
2
2606 }-
2607 assert( pParse->nErr==0 );-
2608 assert( pName->nSrc==1 );-
2609 if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
never executed: goto exit_drop_table;
sqlite3ReadSchema(pParse)Description
TRUEnever evaluated
FALSEevaluated 5261 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
0-5261
2610 if( noErr ) db->suppressErr++;
executed 558 times by 2 tests: db->suppressErr++;
Executed by:
  • Self test (438)
  • Self test (47)
noErrDescription
TRUEevaluated 558 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 4703 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
558-4703
2611 assert( isView==0 || isView==LOCATE_VIEW );-
2612 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);-
2613 if( noErr ) db->suppressErr--;
executed 558 times by 2 tests: db->suppressErr--;
Executed by:
  • Self test (438)
  • Self test (47)
noErrDescription
TRUEevaluated 558 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 4703 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
558-4703
2614-
2615 if( pTab==0 ){
pTab==0Description
TRUEevaluated 321 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 4940 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
321-4940
2616 if( noErr ) sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
executed 281 times by 2 tests: sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);
Executed by:
  • Self test (438)
  • Self test (47)
noErrDescription
TRUEevaluated 281 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 40 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
40-281
2617 goto exit_drop_table;
executed 321 times by 2 tests: goto exit_drop_table;
Executed by:
  • Self test (438)
  • Self test (47)
321
2618 }-
2619 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);-
2620 assert( iDb>=0 && iDb<db->nDb );-
2621-
2622 /* If pTab is a virtual table, call ViewGetColumnNames() to ensure-
2623 ** it is initialized.-
2624 */-
2625 if( IsVirtual(pTab) && sqlite3ViewGetColumnNames(pParse, pTab) ){
((pTab)->nModuleArg)Description
TRUEevaluated 67 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4873 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
sqlite3ViewGet...(pParse, pTab)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test (438)
1-4873
2626 goto exit_drop_table;
executed 1 time by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
1
2627 }-
2628#ifndef SQLITE_OMIT_AUTHORIZATION-
2629 {-
2630 int code;-
2631 const char *zTab = SCHEMA_TABLE(iDb);
(iDb==1)Description
TRUEevaluated 121 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4818 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
121-4818
2632 const char *zDb = db->aDb[iDb].zDbSName;-
2633 const char *zArg2 = 0;-
2634 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb)){
sqlite3AuthChe... zTab, 0, zDb)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4930 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
9-4930
2635 goto exit_drop_table;
executed 9 times by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
9
2636 }-
2637 if( isView ){
isViewDescription
TRUEevaluated 92 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
FALSEevaluated 4838 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
92-4838
2638 if( !OMIT_TEMPDB && iDb==1 ){
iDb==1Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 81 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
11-81
2639 code = SQLITE_DROP_TEMP_VIEW;-
2640 }else{
executed 11 times by 1 test: end of block
Executed by:
  • Self test (438)
11
2641 code = SQLITE_DROP_VIEW;-
2642 }
executed 81 times by 3 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
81
2643#ifndef SQLITE_OMIT_VIRTUALTABLE-
2644 }else if( IsVirtual(pTab) ){
((pTab)->nModuleArg)Description
TRUEevaluated 65 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4773 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
65-4773
2645 code = SQLITE_DROP_VTABLE;-
2646 zArg2 = sqlite3GetVTable(db, pTab)->pMod->zName;-
2647#endif-
2648 }else{
executed 65 times by 1 test: end of block
Executed by:
  • Self test (438)
65
2649 if( !OMIT_TEMPDB && iDb==1 ){
iDb==1Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4684 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
89-4684
2650 code = SQLITE_DROP_TEMP_TABLE;-
2651 }else{
executed 89 times by 1 test: end of block
Executed by:
  • Self test (438)
89
2652 code = SQLITE_DROP_TABLE;-
2653 }
executed 4684 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4684
2654 }-
2655 if( sqlite3AuthCheck(pParse, code, pTab->zName, zArg2, zDb) ){
sqlite3AuthChe...e, zArg2, zDb)Description
TRUEevaluated 9 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4921 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
9-4921
2656 goto exit_drop_table;
executed 9 times by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
9
2657 }-
2658 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, pTab->zName, 0, zDb) ){
sqlite3AuthChe...zName, 0, zDb)Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4916 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5-4916
2659 goto exit_drop_table;
executed 5 times by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
5
2660 }-
2661 }-
2662#endif-
2663 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
sqlite3_strnic...qlite_", 7)==0Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4913 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
3-4913
2664 && sqlite3StrNICmp(pTab->zName, "sqlite_stat", 11)!=0 ){
sqlite3_strnic..._stat", 11)!=0Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-2
2665 sqlite3ErrorMsg(pParse, "table %s may not be dropped", pTab->zName);-
2666 goto exit_drop_table;
executed 2 times by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
2
2667 }-
2668-
2669#ifndef SQLITE_OMIT_VIEW-
2670 /* Ensure DROP TABLE is not used on a view, and DROP VIEW is not used-
2671 ** on a table.-
2672 */-
2673 if( isView && pTab->pSelect==0 ){
isViewDescription
TRUEevaluated 88 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
FALSEevaluated 4826 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
pTab->pSelect==0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 87 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
1-4826
2674 sqlite3ErrorMsg(pParse, "use DROP TABLE to delete table %s", pTab->zName);-
2675 goto exit_drop_table;
executed 1 time by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
1
2676 }-
2677 if( !isView && pTab->pSelect ){
!isViewDescription
TRUEevaluated 4826 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 87 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
pTab->pSelectDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4825 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
1-4826
2678 sqlite3ErrorMsg(pParse, "use DROP VIEW to delete view %s", pTab->zName);-
2679 goto exit_drop_table;
executed 1 time by 1 test: goto exit_drop_table;
Executed by:
  • Self test (438)
1
2680 }-
2681#endif-
2682-
2683 /* Generate code to remove the table from the master table-
2684 ** on disk.-
2685 */-
2686 v = sqlite3GetVdbe(pParse);-
2687 if( v ){
vDescription
TRUEevaluated 4911 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-4911
2688 sqlite3BeginWriteOperation(pParse, 1, iDb);-
2689 if( !isView ){
!isViewDescription
TRUEevaluated 4824 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEevaluated 87 times by 3 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
87-4824
2690 sqlite3ClearStatTables(pParse, iDb, "tbl", pTab->zName);-
2691 sqlite3FkDropTable(pParse, pName, pTab);-
2692 }
executed 4824 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4824
2693 sqlite3CodeDropTable(pParse, pTab, iDb, isView);-
2694 }
executed 4911 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4911
2695-
2696exit_drop_table:
code before this statement executed 4912 times by 4 tests: exit_drop_table:
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4912
2697 sqlite3SrcListDelete(db, pName);-
2698}
executed 5263 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5263
2699-
2700/*-
2701** This routine is called to create a new foreign key on the table-
2702** currently under construction. pFromCol determines which columns-
2703** in the current table point to the foreign key. If pFromCol==0 then-
2704** connect the key to the last column inserted. pTo is the name of-
2705** the table referred to (a.k.a the "parent" table). pToCol is a list-
2706** of tables in the parent pTo table. flags contains all-
2707** information about the conflict resolution algorithms specified-
2708** in the ON DELETE, ON UPDATE and ON INSERT clauses.-
2709**-
2710** An FKey structure is created and added to the table currently-
2711** under construction in the pParse->pNewTable field.-
2712**-
2713** The foreign key is set for IMMEDIATE processing. A subsequent call-
2714** to sqlite3DeferForeignKey() might change this to DEFERRED.-
2715*/-
2716void sqlite3CreateForeignKey(-
2717 Parse *pParse, /* Parsing context */-
2718 ExprList *pFromCol, /* Columns in this table that point to other table */-
2719 Token *pTo, /* Name of the other table */-
2720 ExprList *pToCol, /* Columns in the other table */-
2721 int flags /* Conflict resolution algorithms. */-
2722){-
2723 sqlite3 *db = pParse->db;-
2724#ifndef SQLITE_OMIT_FOREIGN_KEY-
2725 FKey *pFKey = 0;-
2726 FKey *pNextTo;-
2727 Table *p = pParse->pNewTable;-
2728 int nByte;-
2729 int i;-
2730 int nCol;-
2731 char *z;-
2732-
2733 assert( pTo!=0 );-
2734 if( p==0 || IN_DECLARE_VTAB ) goto fk_end;
executed 2 times by 1 test: goto fk_end;
Executed by:
  • Self test (438)
p==0Description
TRUEnever evaluated
FALSEevaluated 1253 times by 1 test
Evaluated by:
  • Self test (438)
(pParse->eParseMode==1)Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1251 times by 1 test
Evaluated by:
  • Self test (438)
0-1253
2735 if( pFromCol==0 ){
pFromCol==0Description
TRUEevaluated 975 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 276 times by 1 test
Evaluated by:
  • Self test (438)
276-975
2736 int iCol = p->nCol-1;-
2737 if( NEVER(iCol<0) ) goto fk_end;
never executed: goto fk_end;
(iCol<0)Description
TRUEnever evaluated
FALSEevaluated 975 times by 1 test
Evaluated by:
  • Self test (438)
0-975
2738 if( pToCol && pToCol->nExpr!=1 ){
pToColDescription
TRUEevaluated 225 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 750 times by 1 test
Evaluated by:
  • Self test (438)
pToCol->nExpr!=1Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 224 times by 1 test
Evaluated by:
  • Self test (438)
1-750
2739 sqlite3ErrorMsg(pParse, "foreign key on %s"-
2740 " should reference only one column of table %T",-
2741 p->aCol[iCol].zName, pTo);-
2742 goto fk_end;
executed 1 time by 1 test: goto fk_end;
Executed by:
  • Self test (438)
1
2743 }-
2744 nCol = 1;-
2745 }else if( pToCol && pToCol->nExpr!=pFromCol->nExpr ){
executed 974 times by 1 test: end of block
Executed by:
  • Self test (438)
pToColDescription
TRUEevaluated 141 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 135 times by 1 test
Evaluated by:
  • Self test (438)
pToCol->nExpr!=pFromCol->nExprDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 139 times by 1 test
Evaluated by:
  • Self test (438)
2-974
2746 sqlite3ErrorMsg(pParse,-
2747 "number of columns in foreign key does not match the number of "-
2748 "columns in the referenced table");-
2749 goto fk_end;
executed 2 times by 1 test: goto fk_end;
Executed by:
  • Self test (438)
2
2750 }else{-
2751 nCol = pFromCol->nExpr;-
2752 }
executed 274 times by 1 test: end of block
Executed by:
  • Self test (438)
274
2753 nByte = sizeof(*pFKey) + (nCol-1)*sizeof(pFKey->aCol[0]) + pTo->n + 1;-
2754 if( pToCol ){
pToColDescription
TRUEevaluated 363 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 885 times by 1 test
Evaluated by:
  • Self test (438)
363-885
2755 for(i=0; i<pToCol->nExpr; i++){
i<pToCol->nExprDescription
TRUEevaluated 466 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 363 times by 1 test
Evaluated by:
  • Self test (438)
363-466
2756 nByte += sqlite3Strlen30(pToCol->a[i].zName) + 1;-
2757 }
executed 466 times by 1 test: end of block
Executed by:
  • Self test (438)
466
2758 }
executed 363 times by 1 test: end of block
Executed by:
  • Self test (438)
363
2759 pFKey = sqlite3DbMallocZero(db, nByte );-
2760 if( pFKey==0 ){
pFKey==0Description
TRUEnever evaluated
FALSEevaluated 1248 times by 1 test
Evaluated by:
  • Self test (438)
0-1248
2761 goto fk_end;
never executed: goto fk_end;
0
2762 }-
2763 pFKey->pFrom = p;-
2764 pFKey->pNextFrom = p->pFKey;-
2765 z = (char*)&pFKey->aCol[nCol];-
2766 pFKey->zTo = z;-
2767 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 148 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1100 times by 1 test
Evaluated by:
  • Self test (438)
148-1100
2768 sqlite3RenameTokenMap(pParse, (void*)z, pTo);-
2769 }
executed 148 times by 1 test: end of block
Executed by:
  • Self test (438)
148
2770 memcpy(z, pTo->z, pTo->n);-
2771 z[pTo->n] = 0;-
2772 sqlite3Dequote(z);-
2773 z += pTo->n+1;-
2774 pFKey->nCol = nCol;-
2775 if( pFromCol==0 ){
pFromCol==0Description
TRUEevaluated 974 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 274 times by 1 test
Evaluated by:
  • Self test (438)
274-974
2776 pFKey->aCol[0].iFrom = p->nCol-1;-
2777 }else{
executed 974 times by 1 test: end of block
Executed by:
  • Self test (438)
974
2778 for(i=0; i<nCol; i++){
i<nColDescription
TRUEevaluated 695 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 270 times by 1 test
Evaluated by:
  • Self test (438)
270-695
2779 int j;-
2780 for(j=0; j<p->nCol; j++){
j<p->nColDescription
TRUEevaluated 3308 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-3308
2781 if( sqlite3StrICmp(p->aCol[j].zName, pFromCol->a[i].zName)==0 ){
sqlite3StrICmp...a[i].zName)==0Description
TRUEevaluated 691 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2617 times by 1 test
Evaluated by:
  • Self test (438)
691-2617
2782 pFKey->aCol[i].iFrom = j;-
2783 break;
executed 691 times by 1 test: break;
Executed by:
  • Self test (438)
691
2784 }-
2785 }
executed 2617 times by 1 test: end of block
Executed by:
  • Self test (438)
2617
2786 if( j>=p->nCol ){
j>=p->nColDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 691 times by 1 test
Evaluated by:
  • Self test (438)
4-691
2787 sqlite3ErrorMsg(pParse, -
2788 "unknown column \"%s\" in foreign key definition", -
2789 pFromCol->a[i].zName);-
2790 goto fk_end;
executed 4 times by 1 test: goto fk_end;
Executed by:
  • Self test (438)
4
2791 }-
2792 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 222 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 469 times by 1 test
Evaluated by:
  • Self test (438)
222-469
2793 sqlite3RenameTokenRemap(pParse, &pFKey->aCol[i], pFromCol->a[i].zName);-
2794 }
executed 222 times by 1 test: end of block
Executed by:
  • Self test (438)
222
2795 }
executed 691 times by 1 test: end of block
Executed by:
  • Self test (438)
691
2796 }
executed 270 times by 1 test: end of block
Executed by:
  • Self test (438)
270
2797 if( pToCol ){
pToColDescription
TRUEevaluated 359 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 885 times by 1 test
Evaluated by:
  • Self test (438)
359-885
2798 for(i=0; i<nCol; i++){
i<nColDescription
TRUEevaluated 460 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 359 times by 1 test
Evaluated by:
  • Self test (438)
359-460
2799 int n = sqlite3Strlen30(pToCol->a[i].zName);-
2800 pFKey->aCol[i].zCol = z;-
2801 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 432 times by 1 test
Evaluated by:
  • Self test (438)
28-432
2802 sqlite3RenameTokenRemap(pParse, z, pToCol->a[i].zName);-
2803 }
executed 28 times by 1 test: end of block
Executed by:
  • Self test (438)
28
2804 memcpy(z, pToCol->a[i].zName, n);-
2805 z[n] = 0;-
2806 z += n+1;-
2807 }
executed 460 times by 1 test: end of block
Executed by:
  • Self test (438)
460
2808 }
executed 359 times by 1 test: end of block
Executed by:
  • Self test (438)
359
2809 pFKey->isDeferred = 0;-
2810 pFKey->aAction[0] = (u8)(flags & 0xff); /* ON DELETE action */-
2811 pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */-
2812-
2813 assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) );-
2814 pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash, -
2815 pFKey->zTo, (void *)pFKey-
2816 );-
2817 if( pNextTo==pFKey ){
pNextTo==pFKeyDescription
TRUEnever evaluated
FALSEevaluated 1244 times by 1 test
Evaluated by:
  • Self test (438)
0-1244
2818 sqlite3OomFault(db);-
2819 goto fk_end;
never executed: goto fk_end;
0
2820 }-
2821 if( pNextTo ){
pNextToDescription
TRUEevaluated 422 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 822 times by 1 test
Evaluated by:
  • Self test (438)
422-822
2822 assert( pNextTo->pPrevTo==0 );-
2823 pFKey->pNextTo = pNextTo;-
2824 pNextTo->pPrevTo = pFKey;-
2825 }
executed 422 times by 1 test: end of block
Executed by:
  • Self test (438)
422
2826-
2827 /* Link the foreign key to the table as the last step.-
2828 */-
2829 p->pFKey = pFKey;-
2830 pFKey = 0;-
2831-
2832fk_end:
code before this statement executed 1244 times by 1 test: fk_end:
Executed by:
  • Self test (438)
1244
2833 sqlite3DbFree(db, pFKey);-
2834#endif /* !defined(SQLITE_OMIT_FOREIGN_KEY) */-
2835 sqlite3ExprListDelete(db, pFromCol);-
2836 sqlite3ExprListDelete(db, pToCol);-
2837}
executed 1253 times by 1 test: end of block
Executed by:
  • Self test (438)
1253
2838-
2839/*-
2840** This routine is called when an INITIALLY IMMEDIATE or INITIALLY DEFERRED-
2841** clause is seen as part of a foreign key definition. The isDeferred-
2842** parameter is 1 for INITIALLY DEFERRED and 0 for INITIALLY IMMEDIATE.-
2843** The behavior of the most recently created foreign key is adjusted-
2844** accordingly.-
2845*/-
2846void sqlite3DeferForeignKey(Parse *pParse, int isDeferred){-
2847#ifndef SQLITE_OMIT_FOREIGN_KEY-
2848 Table *pTab;-
2849 FKey *pFKey;-
2850 if( (pTab = pParse->pNewTable)==0 || (pFKey = pTab->pFKey)==0 ) return;
executed 10 times by 1 test: return;
Executed by:
  • Self test (438)
(pTab = pParse->pNewTable)==0Description
TRUEnever evaluated
FALSEevaluated 395 times by 1 test
Evaluated by:
  • Self test (438)
(pFKey = pTab->pFKey)==0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 385 times by 1 test
Evaluated by:
  • Self test (438)
0-395
2851 assert( isDeferred==0 || isDeferred==1 ); /* EV: R-30323-21917 */-
2852 pFKey->isDeferred = (u8)isDeferred;-
2853#endif-
2854}
executed 385 times by 1 test: end of block
Executed by:
  • Self test (438)
385
2855-
2856/*-
2857** Generate code that will erase and refill index *pIdx. This is-
2858** used to initialize a newly created index or to recompute the-
2859** content of an index in response to a REINDEX command.-
2860**-
2861** if memRootPage is not negative, it means that the index is newly-
2862** created. The register specified by memRootPage contains the-
2863** root page number of the index. If memRootPage is negative, then-
2864** the index already exists and must be cleared before being refilled and-
2865** the root page number of the index is taken from pIndex->tnum.-
2866*/-
2867static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){-
2868 Table *pTab = pIndex->pTable; /* The table that is indexed */-
2869 int iTab = pParse->nTab++; /* Btree cursor used for pTab */-
2870 int iIdx = pParse->nTab++; /* Btree cursor used for pIndex */-
2871 int iSorter; /* Cursor opened by OpenSorter (if in use) */-
2872 int addr1; /* Address of top of loop */-
2873 int addr2; /* Address to jump to for next iteration */-
2874 int tnum; /* Root page of index */-
2875 int iPartIdxLabel; /* Jump to this label to skip a row */-
2876 Vdbe *v; /* Generate code into this virtual machine */-
2877 KeyInfo *pKey; /* KeyInfo for index */-
2878 int regRecord; /* Register holding assembled index record */-
2879 sqlite3 *db = pParse->db; /* The database connection */-
2880 int iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);-
2881-
2882#ifndef SQLITE_OMIT_AUTHORIZATION-
2883 if( sqlite3AuthCheck(pParse, SQLITE_REINDEX, pIndex->zName, 0,
sqlite3AuthChe...Db].zDbSName )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2632 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
3-2632
2884 db->aDb[iDb].zDbSName ) ){
sqlite3AuthChe...Db].zDbSName )Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2632 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
3-2632
2885 return;
executed 3 times by 1 test: return;
Executed by:
  • Self test (438)
3
2886 }-
2887#endif-
2888-
2889 /* Require a write-lock on the table to perform this operation */-
2890 sqlite3TableLock(pParse, iDb, pTab->tnum, 1, pTab->zName);-
2891-
2892 v = sqlite3GetVdbe(pParse);-
2893 if( v==0 ) return;
never executed: return;
v==0Description
TRUEnever evaluated
FALSEevaluated 2632 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
0-2632
2894 if( memRootPage>=0 ){
memRootPage>=0Description
TRUEevaluated 2425 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 207 times by 1 test
Evaluated by:
  • Self test (438)
207-2425
2895 tnum = memRootPage;-
2896 }else{
executed 2425 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2425
2897 tnum = pIndex->tnum;-
2898 }
executed 207 times by 1 test: end of block
Executed by:
  • Self test (438)
207
2899 pKey = sqlite3KeyInfoOfIndex(pParse, pIndex);-
2900 assert( pKey!=0 || db->mallocFailed || pParse->nErr );-
2901-
2902 /* Open the sorter cursor if we are to use one. */-
2903 iSorter = pParse->nTab++;-
2904 sqlite3VdbeAddOp4(v, OP_SorterOpen, iSorter, 0, pIndex->nKeyCol, (char*)-
2905 sqlite3KeyInfoRef(pKey), P4_KEYINFO);-
2906-
2907 /* Open the table. Loop through all rows of the table, inserting index-
2908 ** records into the sorter. */-
2909 sqlite3OpenTable(pParse, iTab, iDb, pTab, OP_OpenRead);-
2910 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iTab, 0); VdbeCoverage(v);-
2911 regRecord = sqlite3GetTempReg(pParse);-
2912 sqlite3MultiWrite(pParse);-
2913-
2914 sqlite3GenerateIndexKey(pParse,pIndex,iTab,regRecord,0,&iPartIdxLabel,0,0);-
2915 sqlite3VdbeAddOp2(v, OP_SorterInsert, iSorter, regRecord);-
2916 sqlite3ResolvePartIdxLabel(pParse, iPartIdxLabel);-
2917 sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);-
2918 sqlite3VdbeJumpHere(v, addr1);-
2919 if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
executed 207 times by 1 test: sqlite3VdbeAddOp2(v, 138, tnum, iDb);
Executed by:
  • Self test (438)
memRootPage<0Description
TRUEevaluated 207 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2425 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
207-2425
2920 sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, -
2921 (char *)pKey, P4_KEYINFO);-
2922 sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));-
2923-
2924 addr1 = sqlite3VdbeAddOp2(v, OP_SorterSort, iSorter, 0); VdbeCoverage(v);-
2925 if( IsUniqueIndex(pIndex) ){
((pIndex)->onError!=0)Description
TRUEevaluated 230 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2402 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
230-2402
2926 int j2 = sqlite3VdbeGoto(v, 1);-
2927 addr2 = sqlite3VdbeCurrentAddr(v);-
2928 sqlite3VdbeVerifyAbortable(v, OE_Abort);-
2929 sqlite3VdbeAddOp4Int(v, OP_SorterCompare, iSorter, j2, regRecord,-
2930 pIndex->nKeyCol); VdbeCoverage(v);-
2931 sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);-
2932 sqlite3VdbeJumpHere(v, j2);-
2933 }else{
executed 230 times by 1 test: end of block
Executed by:
  • Self test (438)
230
2934 addr2 = sqlite3VdbeCurrentAddr(v);-
2935 }
executed 2402 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2402
2936 sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);-
2937 sqlite3VdbeAddOp1(v, OP_SeekEnd, iIdx);-
2938 sqlite3VdbeAddOp2(v, OP_IdxInsert, iIdx, regRecord);-
2939 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);-
2940 sqlite3ReleaseTempReg(pParse, regRecord);-
2941 sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);-
2942 sqlite3VdbeJumpHere(v, addr1);-
2943-
2944 sqlite3VdbeAddOp1(v, OP_Close, iTab);-
2945 sqlite3VdbeAddOp1(v, OP_Close, iIdx);-
2946 sqlite3VdbeAddOp1(v, OP_Close, iSorter);-
2947}
executed 2632 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2632
2948-
2949/*-
2950** Allocate heap space to hold an Index object with nCol columns.-
2951**-
2952** Increase the allocation size to provide an extra nExtra bytes-
2953** of 8-byte aligned space after the Index object and return a-
2954** pointer to this extra space in *ppExtra.-
2955*/-
2956Index *sqlite3AllocateIndexObject(-
2957 sqlite3 *db, /* Database connection */-
2958 i16 nCol, /* Total number of columns in the index */-
2959 int nExtra, /* Number of bytes of extra space to alloc */-
2960 char **ppExtra /* Pointer to the "extra" space */-
2961){-
2962 Index *p; /* Allocated index object */-
2963 int nByte; /* Bytes of space for Index object + arrays */-
2964-
2965 nByte = ROUND8(sizeof(Index)) + /* Index structure */-
2966 ROUND8(sizeof(char*)*nCol) + /* Index.azColl */-
2967 ROUND8(sizeof(LogEst)*(nCol+1) + /* Index.aiRowLogEst */-
2968 sizeof(i16)*nCol + /* Index.aiColumn */-
2969 sizeof(u8)*nCol); /* Index.aSortOrder */-
2970 p = sqlite3DbMallocZero(db, nByte + nExtra);-
2971 if( p ){
pDescription
TRUEevaluated 16229 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEnever evaluated
0-16229
2972 char *pExtra = ((char*)p)+ROUND8(sizeof(Index));-
2973 p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);-
2974 p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);-
2975 p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol;-
2976 p->aSortOrder = (u8*)pExtra;-
2977 p->nColumn = nCol;-
2978 p->nKeyCol = nCol - 1;-
2979 *ppExtra = ((char*)p) + nByte;-
2980 }
executed 16229 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
16229
2981 return p;
executed 16229 times by 394 tests: return p;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
16229
2982}-
2983-
2984/*-
2985** Create a new index for an SQL table. pName1.pName2 is the name of the index -
2986** and pTblList is the name of the table that is to be indexed. Both will -
2987** be NULL for a primary key or an index that is created to satisfy a-
2988** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable-
2989** as the table to be indexed. pParse->pNewTable is a table that is-
2990** currently being constructed by a CREATE TABLE statement.-
2991**-
2992** pList is a list of columns to be indexed. pList will be NULL if this-
2993** is a primary key or unique-constraint on the most recent column added-
2994** to the table currently under construction. -
2995*/-
2996void sqlite3CreateIndex(-
2997 Parse *pParse, /* All information about this parse */-
2998 Token *pName1, /* First part of index name. May be NULL */-
2999 Token *pName2, /* Second part of index name. May be NULL */-
3000 SrcList *pTblName, /* Table to index. Use pParse->pNewTable if 0 */-
3001 ExprList *pList, /* A list of columns to be indexed */-
3002 int onError, /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */-
3003 Token *pStart, /* The CREATE token that begins this statement */-
3004 Expr *pPIWhere, /* WHERE clause for partial indices */-
3005 int sortOrder, /* Sort order of primary key when pList==NULL */-
3006 int ifNotExist, /* Omit error if index already exists */-
3007 u8 idxType /* The index type */-
3008){-
3009 Table *pTab = 0; /* Table to be indexed */-
3010 Index *pIndex = 0; /* The index to be created */-
3011 char *zName = 0; /* Name of the index */-
3012 int nName; /* Number of characters in zName */-
3013 int i, j;-
3014 DbFixer sFix; /* For assigning database names to pTable */-
3015 int sortOrderMask; /* 1 to honor DESC in index. 0 to ignore. */-
3016 sqlite3 *db = pParse->db;-
3017 Db *pDb; /* The specific table containing the indexed database */-
3018 int iDb; /* Index of the database that is being written */-
3019 Token *pName = 0; /* Unqualified name of the index to create */-
3020 struct ExprList_item *pListItem; /* For looping over pList */-
3021 int nExtra = 0; /* Space allocated for zExtra[] */-
3022 int nExtraCol; /* Number of extra columns needed */-
3023 char *zExtra = 0; /* Extra space after the Index object */-
3024 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */-
3025-
3026 if( db->mallocFailed || pParse->nErr>0 ){
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 13412 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
pParse->nErr>0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13411 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
0-13412
3027 goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
1
3028 }-
3029 if( IN_DECLARE_VTAB && idxType!=SQLITE_IDXTYPE_PRIMARYKEY ){
(pParse->eParseMode==1)Description
TRUEevaluated 44 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13367 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
idxType!=2Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 39 times by 1 test
Evaluated by:
  • Self test (438)
5-13367
3030 goto exit_create_index;
executed 5 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
5
3031 }-
3032 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
0!=sqlite3ReadSchema(pParse)Description
TRUEnever evaluated
FALSEevaluated 13406 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
0-13406
3033 goto exit_create_index;
never executed: goto exit_create_index;
0
3034 }-
3035-
3036 /*-
3037 ** Find the table that is to be indexed. Return early if not found.-
3038 */-
3039 if( pTblName!=0 ){
pTblName!=0Description
TRUEevaluated 6646 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 6760 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6646-6760
3040-
3041 /* Use the two-part index name to determine the database -
3042 ** to search for the table. 'Fix' the table name to this db-
3043 ** before looking up the table.-
3044 */-
3045 assert( pName1 && pName2 );-
3046 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);-
3047 if( iDb<0 ) goto exit_create_index;
never executed: goto exit_create_index;
iDb<0Description
TRUEnever evaluated
FALSEevaluated 6646 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
0-6646
3048 assert( pName && pName->z );-
3049-
3050#ifndef SQLITE_OMIT_TEMPDB-
3051 /* If the index name was unqualified, check if the table-
3052 ** is a temp table. If so, set the database to 1. Do not do this-
3053 ** if initialising a database schema.-
3054 */-
3055 if( !db->init.busy ){
!db->init.busyDescription
TRUEevaluated 2582 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 4064 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
2582-4064
3056 pTab = sqlite3SrcListLookup(pParse, pTblName);-
3057 if( pName2->n==0 && pTab && pTab->pSchema==db->aDb[1].pSchema ){
pName2->n==0Description
TRUEevaluated 2545 times by 9 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 37 times by 2 tests
Evaluated by:
  • Self test (27)
  • Self test (438)
pTabDescription
TRUEevaluated 2538 times by 9 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 7 times by 4 tests
Evaluated by:
  • Self test (26)
  • Self test (29)
  • Self test (438)
  • Self test (47)
pTab->pSchema=...aDb[1].pSchemaDescription
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2510 times by 9 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
7-2545
3058 iDb = 1;-
3059 }
executed 28 times by 1 test: end of block
Executed by:
  • Self test (438)
28
3060 }
executed 2582 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2582
3061#endif-
3062-
3063 sqlite3FixInit(&sFix, pParse, iDb, "index", pName);-
3064 if( sqlite3FixSrcList(&sFix, pTblName) ){
sqlite3FixSrcL...Fix, pTblName)Description
TRUEnever evaluated
FALSEevaluated 6646 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
0-6646
3065 /* Because the parser constructs pTblName from a single identifier,-
3066 ** sqlite3FixSrcList can never fail. */-
3067 assert(0);-
3068 }
never executed: end of block
0
3069 pTab = sqlite3LocateTableItem(pParse, 0, &pTblName->a[0]);-
3070 assert( db->mallocFailed==0 || pTab==0 );-
3071 if( pTab==0 ) goto exit_create_index;
executed 10 times by 5 tests: goto exit_create_index;
Executed by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (438)
  • Self test (47)
pTab==0Description
TRUEevaluated 10 times by 5 tests
Evaluated by:
  • Self test (26)
  • Self test (27)
  • Self test (29)
  • Self test (438)
  • Self test (47)
FALSEevaluated 6636 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
10-6636
3072 if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
iDb==1Description
TRUEevaluated 61 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6575 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
db->aDb[iDb].p...=pTab->pSchemaDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 60 times by 1 test
Evaluated by:
  • Self test (438)
1-6575
3073 sqlite3ErrorMsg(pParse, -
3074 "cannot create a TEMP index on non-TEMP table \"%s\"",-
3075 pTab->zName);-
3076 goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
1
3077 }-
3078 if( !HasRowid(pTab) ) pPk = sqlite3PrimaryKeyIndex(pTab);
executed 208 times by 1 test: pPk = sqlite3PrimaryKeyIndex(pTab);
Executed by:
  • Self test (438)
!(((pTab)->tab... & 0x0020)==0)Description
TRUEevaluated 208 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6427 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
208-6427
3079 }else{
executed 6635 times by 24 tests: end of block
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
6635
3080 assert( pName==0 );-
3081 assert( pStart==0 );-
3082 pTab = pParse->pNewTable;-
3083 if( !pTab ) goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
!pTabDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6759 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
1-6759
3084 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);-
3085 }
executed 6759 times by 376 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6759
3086 pDb = &db->aDb[iDb];-
3087-
3088 assert( pTab!=0 );-
3089 assert( pParse->nErr==0 );-
3090 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
sqlite3_strnic...qlite_", 7)==0Description
TRUEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13383 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
11-13383
3091 && db->init.busy==0
db->init.busy==0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-10
3092#if SQLITE_USER_AUTHENTICATION-
3093 && sqlite3UserAuthTable(pTab->zName)==0-
3094#endif-
3095#ifdef SQLITE_ALLOW_SQLITE_MASTER_INDEX-
3096 && sqlite3StrICmp(&pTab->zName[7],"master")!=0-
3097#endif-
3098 && sqlite3StrNICmp(&pTab->zName[7],"altertab_",9)!=0
sqlite3_strnic...tertab_",9)!=0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
4-6
3099 ){-
3100 sqlite3ErrorMsg(pParse, "table %s may not be indexed", pTab->zName);-
3101 goto exit_create_index;
executed 4 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
4
3102 }-
3103#ifndef SQLITE_OMIT_VIEW-
3104 if( pTab->pSelect ){
pTab->pSelectDescription
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13389 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
1-13389
3105 sqlite3ErrorMsg(pParse, "views may not be indexed");-
3106 goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
1
3107 }-
3108#endif-
3109#ifndef SQLITE_OMIT_VIRTUALTABLE-
3110 if( IsVirtual(pTab) ){
((pTab)->nModuleArg)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13388 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
1-13388
3111 sqlite3ErrorMsg(pParse, "virtual tables may not be indexed");-
3112 goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
1
3113 }-
3114#endif-
3115-
3116 /*-
3117 ** Find the name of the index. Make sure there is not already another-
3118 ** index or table with the same name. -
3119 **-
3120 ** Exception: If we are reading the names of permanent indices from the-
3121 ** sqlite_master table (because some other process changed the schema) and-
3122 ** one of the index names collides with the name of a temporary table or-
3123 ** index, then we will continue to process this index.-
3124 **-
3125 ** If pName==0 it means that we are-
3126 ** dealing with a primary key or UNIQUE constraint. We have to invent our-
3127 ** own name.-
3128 */-
3129 if( pName ){
pNameDescription
TRUEevaluated 6629 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 6759 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6629-6759
3130 zName = sqlite3NameFromToken(db, pName);-
3131 if( zName==0 ) goto exit_create_index;
never executed: goto exit_create_index;
zName==0Description
TRUEnever evaluated
FALSEevaluated 6629 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
0-6629
3132 assert( pName->z!=0 );-
3133 if( SQLITE_OK!=sqlite3CheckObjectName(pParse, zName) ){
0!=sqlite3Chec...pParse, zName)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6628 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
1-6628
3134 goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
1
3135 }-
3136 if( !IN_RENAME_OBJECT ){
!(pParse->eParseMode>=2)Description
TRUEevaluated 6528 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 100 times by 1 test
Evaluated by:
  • Self test (438)
100-6528
3137 if( !db->init.busy ){
!db->init.busyDescription
TRUEevaluated 2464 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 4064 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
2464-4064
3138 if( sqlite3FindTable(db, zName, 0)!=0 ){
sqlite3FindTab..., zName, 0)!=0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2463 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
1-2463
3139 sqlite3ErrorMsg(pParse, "there is already a table named %s", zName);-
3140 goto exit_create_index;
executed 1 time by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
1
3141 }-
3142 }
executed 2463 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2463
3143 if( sqlite3FindIndex(db, zName, pDb->zDbSName)!=0 ){
sqlite3FindInd...->zDbSName)!=0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6519 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
8-6519
3144 if( !ifNotExist ){
!ifNotExistDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
3-5
3145 sqlite3ErrorMsg(pParse, "index %s already exists", zName);-
3146 }else{
executed 3 times by 1 test: end of block
Executed by:
  • Self test (438)
3
3147 assert( !db->init.busy );-
3148 sqlite3CodeVerifySchema(pParse, iDb);-
3149 }
executed 5 times by 1 test: end of block
Executed by:
  • Self test (438)
5
3150 goto exit_create_index;
executed 8 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
8
3151 }-
3152 }
executed 6519 times by 24 tests: end of block
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
6519
3153 }else{
executed 6619 times by 24 tests: end of block
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
6619
3154 int n;-
3155 Index *pLoop;-
3156 for(pLoop=pTab->pIndex, n=1; pLoop; pLoop=pLoop->pNext, n++){}
executed 672 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (54)
pLoopDescription
TRUEevaluated 672 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
FALSEevaluated 6759 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
672-6759
3157 zName = sqlite3MPrintf(db, "sqlite_autoindex_%s_%d", pTab->zName, n);-
3158 if( zName==0 ){
zName==0Description
TRUEnever evaluated
FALSEevaluated 6759 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
0-6759
3159 goto exit_create_index;
never executed: goto exit_create_index;
0
3160 }-
3161-
3162 /* Automatic index names generated from within sqlite3_declare_vtab()-
3163 ** must have names that are distinct from normal automatic index names.-
3164 ** The following statement converts "sqlite3_autoindex..." into-
3165 ** "sqlite3_butoindex..." in order to make the names distinct.-
3166 ** The "vtab_err.test" test demonstrates the need of this statement. */-
3167 if( IN_SPECIAL_PARSE ) zName[7]++;
executed 198 times by 1 test: zName[7]++;
Executed by:
  • Self test (438)
(pParse->eParseMode!=0)Description
TRUEevaluated 198 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6561 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
198-6561
3168 }
executed 6759 times by 376 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6759
3169-
3170 /* Check for authorization to create an index.-
3171 */-
3172#ifndef SQLITE_OMIT_AUTHORIZATION-
3173 if( !IN_RENAME_OBJECT ){
!(pParse->eParseMode>=2)Description
TRUEevaluated 13119 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 259 times by 1 test
Evaluated by:
  • Self test (438)
259-13119
3174 const char *zDb = pDb->zDbSName;-
3175 if( sqlite3AuthCheck(pParse, SQLITE_INSERT, SCHEMA_TABLE(iDb), 0, zDb) ){
sqlite3AuthChe...ter"), 0, zDb)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13115 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
4-13115
3176 goto exit_create_index;
executed 4 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
4
3177 }-
3178 i = SQLITE_CREATE_INDEX;-
3179 if( !OMIT_TEMPDB && iDb==1 ) i = SQLITE_CREATE_TEMP_INDEX;
executed 125 times by 1 test: i = 3;
Executed by:
  • Self test (438)
iDb==1Description
TRUEevaluated 125 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 12990 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
125-12990
3180 if( sqlite3AuthCheck(pParse, i, zName, pTab->zName, zDb) ){
sqlite3AuthChe...b->zName, zDb)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13111 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
4-13111
3181 goto exit_create_index;
executed 4 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
4
3182 }-
3183 }
executed 13111 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13111
3184#endif-
3185-
3186 /* If pList==0, it means this routine was called to make a primary-
3187 ** key out of the last column added to the table under construction.-
3188 ** So create a fake list to simulate this.-
3189 */-
3190 if( pList==0 ){
pList==0Description
TRUEevaluated 5324 times by 374 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 8046 times by 26 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • ...
5324-8046
3191 Token prevCol;-
3192 Column *pCol = &pTab->aCol[pTab->nCol-1];-
3193 pCol->colFlags |= COLFLAG_UNIQUE;-
3194 sqlite3TokenInit(&prevCol, pCol->zName);-
3195 pList = sqlite3ExprListAppend(pParse, 0,-
3196 sqlite3ExprAlloc(db, TK_ID, &prevCol, 0));-
3197 if( pList==0 ) goto exit_create_index;
never executed: goto exit_create_index;
pList==0Description
TRUEnever evaluated
FALSEevaluated 5324 times by 374 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
0-5324
3198 assert( pList->nExpr==1 );-
3199 sqlite3ExprListSetSortOrder(pList, sortOrder);-
3200 }else{
executed 5324 times by 374 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
5324
3201 sqlite3ExprListCheckLength(pParse, pList, "index");-
3202 }
executed 8046 times by 26 tests: end of block
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (32)
  • Self test (33)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • ...
8046
3203-
3204 /* Figure out how many bytes of space are required to store explicitly-
3205 ** specified collation sequence names.-
3206 */-
3207 for(i=0; i<pList->nExpr; i++){
i<pList->nExprDescription
TRUEevaluated 19463 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 13370 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13370-19463
3208 Expr *pExpr = pList->a[i].pExpr;-
3209 assert( pExpr!=0 );-
3210 if( pExpr->op==TK_COLLATE ){
pExpr->op==102Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 19305 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
158-19305
3211 nExtra += (1 + sqlite3Strlen30(pExpr->u.zToken));-
3212 }
executed 158 times by 1 test: end of block
Executed by:
  • Self test (438)
158
3213 }
executed 19463 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
19463
3214-
3215 /* -
3216 ** Allocate the index structure. -
3217 */-
3218 nName = sqlite3Strlen30(zName);-
3219 nExtraCol = pPk ? pPk->nKeyCol : 1;
pPkDescription
TRUEevaluated 208 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13162 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
208-13162
3220 pIndex = sqlite3AllocateIndexObject(db, pList->nExpr + nExtraCol,-
3221 nName + nExtra + 1, &zExtra);-
3222 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 13370 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
0-13370
3223 goto exit_create_index;
never executed: goto exit_create_index;
0
3224 }-
3225 assert( EIGHT_BYTE_ALIGNMENT(pIndex->aiRowLogEst) );-
3226 assert( EIGHT_BYTE_ALIGNMENT(pIndex->azColl) );-
3227 pIndex->zName = zExtra;-
3228 zExtra += nName + 1;-
3229 memcpy(pIndex->zName, zName, nName+1);-
3230 pIndex->pTable = pTab;-
3231 pIndex->onError = (u8)onError;-
3232 pIndex->uniqNotNull = onError!=OE_None;-
3233 pIndex->idxType = idxType;-
3234 pIndex->pSchema = db->aDb[iDb].pSchema;-
3235 pIndex->nKeyCol = pList->nExpr;-
3236 if( pPIWhere ){
pPIWhereDescription
TRUEevaluated 138 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13232 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
138-13232
3237 sqlite3ResolveSelfReference(pParse, pTab, NC_PartIdx, pPIWhere, 0);-
3238 pIndex->pPartIdxWhere = pPIWhere;-
3239 pPIWhere = 0;-
3240 }
executed 138 times by 1 test: end of block
Executed by:
  • Self test (438)
138
3241 assert( sqlite3SchemaMutexHeld(db, iDb, 0) );-
3242-
3243 /* Check to see if we should honor DESC requests on index columns-
3244 */-
3245 if( pDb->pSchema->file_format>=4 ){
pDb->pSchema->file_format>=4Description
TRUEevaluated 12772 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 598 times by 13 tests
Evaluated by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
598-12772
3246 sortOrderMask = -1; /* Honor DESC */-
3247 }else{
executed 12772 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
12772
3248 sortOrderMask = 0; /* Ignore DESC */-
3249 }
executed 598 times by 13 tests: end of block
Executed by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
598
3250-
3251 /* Analyze the list of expressions that form the terms of the index and-
3252 ** report any errors. In the common case where the expression is exactly-
3253 ** a table column, store that column in aiColumn[]. For general expressions,-
3254 ** populate pIndex->aColExpr and store XN_EXPR (-2) in aiColumn[].-
3255 **-
3256 ** TODO: Issue a warning if two or more columns of the index are identical.-
3257 ** TODO: Issue a warning if the table primary key is used as part of the-
3258 ** index key.-
3259 */-
3260 pListItem = pList->a;-
3261 if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 259 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13111 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
259-13111
3262 pIndex->aColExpr = pList;-
3263 pList = 0;-
3264 }
executed 259 times by 1 test: end of block
Executed by:
  • Self test (438)
259
3265 for(i=0; i<pIndex->nKeyCol; i++, pListItem++){
i<pIndex->nKeyColDescription
TRUEevaluated 19451 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 13339 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13339-19451
3266 Expr *pCExpr; /* The i-th index expression */-
3267 int requestedSortOrder; /* ASC or DESC on the i-th expression */-
3268 const char *zColl; /* Collation sequence name */-
3269-
3270 sqlite3StringToId(pListItem->pExpr);-
3271 sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);-
3272 if( pParse->nErr ) goto exit_create_index;
executed 25 times by 2 tests: goto exit_create_index;
Executed by:
  • Self test (438)
  • Self test (47)
pParse->nErrDescription
TRUEevaluated 25 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 19426 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
25-19426
3273 pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);-
3274 if( pCExpr->op!=TK_COLUMN ){
pCExpr->op!=158Description
TRUEevaluated 124 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 19302 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
124-19302
3275 if( pTab==pParse->pNewTable ){
pTab==pParse->pNewTableDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 121 times by 1 test
Evaluated by:
  • Self test (438)
3-121
3276 sqlite3ErrorMsg(pParse, "expressions prohibited in PRIMARY KEY and "-
3277 "UNIQUE constraints");-
3278 goto exit_create_index;
executed 3 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
3
3279 }-
3280 if( pIndex->aColExpr==0 ){
pIndex->aColExpr==0Description
TRUEevaluated 115 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
6-115
3281 pIndex->aColExpr = pList;-
3282 pList = 0;-
3283 }
executed 115 times by 1 test: end of block
Executed by:
  • Self test (438)
115
3284 j = XN_EXPR;-
3285 pIndex->aiColumn[i] = XN_EXPR;-
3286 pIndex->uniqNotNull = 0;-
3287 }else{
executed 121 times by 1 test: end of block
Executed by:
  • Self test (438)
121
3288 j = pCExpr->iColumn;-
3289 assert( j<=0x7fff );-
3290 if( j<0 ){
j<0Description
TRUEevaluated 124 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 19178 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
124-19178
3291 j = pTab->iPKey;-
3292 }else if( pTab->aCol[j].notNull==0 ){
executed 124 times by 1 test: end of block
Executed by:
  • Self test (438)
pTab->aCol[j].notNull==0Description
TRUEevaluated 18580 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 598 times by 1 test
Evaluated by:
  • Self test (438)
124-18580
3293 pIndex->uniqNotNull = 0;-
3294 }
executed 18580 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
18580
3295 pIndex->aiColumn[i] = (i16)j;-
3296 }
executed 19302 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
19302
3297 zColl = 0;-
3298 if( pListItem->pExpr->op==TK_COLLATE ){
pListItem->pExpr->op==102Description
TRUEevaluated 158 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 19265 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
158-19265
3299 int nColl;-
3300 zColl = pListItem->pExpr->u.zToken;-
3301 nColl = sqlite3Strlen30(zColl) + 1;-
3302 assert( nExtra>=nColl );-
3303 memcpy(zExtra, zColl, nColl);-
3304 zColl = zExtra;-
3305 zExtra += nColl;-
3306 nExtra -= nColl;-
3307 }else if( j>=0 ){
executed 158 times by 1 test: end of block
Executed by:
  • Self test (438)
j>=0Description
TRUEevaluated 19158 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 107 times by 1 test
Evaluated by:
  • Self test (438)
107-19158
3308 zColl = pTab->aCol[j].zColl;-
3309 }
executed 19158 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
19158
3310 if( !zColl ) zColl = sqlite3StrBINARY;
executed 19122 times by 394 tests: zColl = sqlite3StrBINARY;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
!zCollDescription
TRUEevaluated 19122 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 301 times by 1 test
Evaluated by:
  • Self test (438)
301-19122
3311 if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
!db->init.busyDescription
TRUEevaluated 6769 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 12654 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
!sqlite3Locate...pParse, zColl)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 6766 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
3-12654
3312 goto exit_create_index;
executed 3 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
3
3313 }-
3314 pIndex->azColl[i] = zColl;-
3315 requestedSortOrder = pListItem->sortOrder & sortOrderMask;-
3316 pIndex->aSortOrder[i] = (u8)requestedSortOrder;-
3317 }
executed 19420 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
19420
3318-
3319 /* Append the table key to the end of the index. For WITHOUT ROWID-
3320 ** tables (when pPk!=0) this will be the declared PRIMARY KEY. For-
3321 ** normal tables (when pPk==0) this will be the rowid.-
3322 */-
3323 if( pPk ){
pPkDescription
TRUEevaluated 204 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13135 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
204-13135
3324 for(j=0; j<pPk->nKeyCol; j++){
j<pPk->nKeyColDescription
TRUEevaluated 265 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 204 times by 1 test
Evaluated by:
  • Self test (438)
204-265
3325 int x = pPk->aiColumn[j];-
3326 assert( x>=0 );-
3327 if( hasColumn(pIndex->aiColumn, pIndex->nKeyCol, x) ){
hasColumn(pInd...x->nKeyCol, x)Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 218 times by 1 test
Evaluated by:
  • Self test (438)
47-218
3328 pIndex->nColumn--; -
3329 }else{
executed 47 times by 1 test: end of block
Executed by:
  • Self test (438)
47
3330 pIndex->aiColumn[i] = x;-
3331 pIndex->azColl[i] = pPk->azColl[j];-
3332 pIndex->aSortOrder[i] = pPk->aSortOrder[j];-
3333 i++;-
3334 }
executed 218 times by 1 test: end of block
Executed by:
  • Self test (438)
218
3335 }-
3336 assert( i==pIndex->nColumn );-
3337 }else{
executed 204 times by 1 test: end of block
Executed by:
  • Self test (438)
204
3338 pIndex->aiColumn[i] = XN_ROWID;-
3339 pIndex->azColl[i] = sqlite3StrBINARY;-
3340 }
executed 13135 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13135
3341 sqlite3DefaultRowEst(pIndex);-
3342 if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
executed 6586 times by 24 tests: estimateIndexWidth(pIndex);
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
pParse->pNewTable==0Description
TRUEevaluated 6586 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 6753 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6586-6753
3343-
3344 /* If this index contains every column of its table, then mark-
3345 ** it as a covering index */-
3346 assert( HasRowid(pTab) -
3347 || pTab->iPKey<0 || sqlite3ColumnOfIndex(pIndex, pTab->iPKey)>=0 );-
3348 recomputeColumnsNotIndexed(pIndex);-
3349 if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
pTblName!=0Description
TRUEevaluated 6586 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 6753 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
pIndex->nColumn>=pTab->nColDescription
TRUEevaluated 4625 times by 21 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 1961 times by 5 tests
Evaluated by:
  • Self test
  • Self test (438)
  • Self test (47)
  • Self test (57)
  • Self test (58)
1961-6753
3350 pIndex->isCovering = 1;-
3351 for(j=0; j<pTab->nCol; j++){
j<pTab->nColDescription
TRUEevaluated 9184 times by 21 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 2280 times by 19 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
2280-9184
3352 if( j==pTab->iPKey ) continue;
executed 223 times by 1 test: continue;
Executed by:
  • Self test (438)
j==pTab->iPKeyDescription
TRUEevaluated 223 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8961 times by 21 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
223-8961
3353 if( sqlite3ColumnOfIndex(pIndex,j)>=0 ) continue;
executed 6616 times by 19 tests: continue;
Executed by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
sqlite3ColumnO...x(pIndex,j)>=0Description
TRUEevaluated 6616 times by 19 tests
Evaluated by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 2345 times by 6 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (47)
2345-6616
3354 pIndex->isCovering = 0;-
3355 break;
executed 2345 times by 6 tests: break;
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (35)
  • Self test (36)
  • Self test (438)
  • Self test (47)
2345
3356 }-
3357 }
executed 4625 times by 21 tests: end of block
Executed by:
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
4625
3358-
3359 if( pTab==pParse->pNewTable ){
pTab==pParse->pNewTableDescription
TRUEevaluated 6753 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 6586 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
6586-6753
3360 /* This routine has been called to create an automatic index as a-
3361 ** result of a PRIMARY KEY or UNIQUE clause on a column definition, or-
3362 ** a PRIMARY KEY or UNIQUE clause following the column definitions.-
3363 ** i.e. one of:-
3364 **-
3365 ** CREATE TABLE t(x PRIMARY KEY, y);-
3366 ** CREATE TABLE t(x, y, UNIQUE(x, y));-
3367 **-
3368 ** Either way, check to see if the table already has such an index. If-
3369 ** so, don't bother creating this one. This only applies to-
3370 ** automatically created indices. Users can do as they wish with-
3371 ** explicit indices.-
3372 **-
3373 ** Two UNIQUE or PRIMARY KEY constraints are considered equivalent-
3374 ** (and thus suppressing the second one) even if they have different-
3375 ** sort orders.-
3376 **-
3377 ** If there are different collating sequences or if the columns of-
3378 ** the constraint occur in different orders, then the constraints are-
3379 ** considered distinct and both result in separate indices.-
3380 */-
3381 Index *pIdx;-
3382 for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
pIdxDescription
TRUEevaluated 666 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
FALSEevaluated 6687 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
666-6687
3383 int k;-
3384 assert( IsUniqueIndex(pIdx) );-
3385 assert( pIdx->idxType!=SQLITE_IDXTYPE_APPDEF );-
3386 assert( IsUniqueIndex(pIndex) );-
3387-
3388 if( pIdx->nKeyCol!=pIndex->nKeyCol ) continue;
executed 52 times by 1 test: continue;
Executed by:
  • Self test (438)
pIdx->nKeyCol!=pIndex->nKeyColDescription
TRUEevaluated 52 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 614 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
52-614
3389 for(k=0; k<pIdx->nKeyCol; k++){
k<pIdx->nKeyColDescription
TRUEevaluated 618 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
FALSEevaluated 66 times by 1 test
Evaluated by:
  • Self test (438)
66-618
3390 const char *z1;-
3391 const char *z2;-
3392 assert( pIdx->aiColumn[k]>=0 );-
3393 if( pIdx->aiColumn[k]!=pIndex->aiColumn[k] ) break;
executed 548 times by 2 tests: break;
Executed by:
  • Self test (438)
  • Self test (54)
pIdx->aiColumn...x->aiColumn[k]Description
TRUEevaluated 548 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test (438)
70-548
3394 z1 = pIdx->azColl[k];-
3395 z2 = pIndex->azColl[k];-
3396 if( sqlite3StrICmp(z1, z2) ) break;
never executed: break;
sqlite3StrICmp(z1, z2)Description
TRUEnever evaluated
FALSEevaluated 70 times by 1 test
Evaluated by:
  • Self test (438)
0-70
3397 }
executed 70 times by 1 test: end of block
Executed by:
  • Self test (438)
70
3398 if( k==pIdx->nKeyCol ){
k==pIdx->nKeyColDescription
TRUEevaluated 66 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 548 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (54)
66-548
3399 if( pIdx->onError!=pIndex->onError ){
pIdx->onError!=pIndex->onErrorDescription
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test (438)
3-63
3400 /* This constraint creates the same index as a previous-
3401 ** constraint specified somewhere in the CREATE TABLE statement.-
3402 ** However the ON CONFLICT clauses are different. If both this -
3403 ** constraint and the previous equivalent constraint have explicit-
3404 ** ON CONFLICT clauses this is an error. Otherwise, use the-
3405 ** explicitly specified behavior for the index.-
3406 */-
3407 if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
pIdx->onError==11Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
pIndex->onError==11Description
TRUEnever evaluated
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
0-2
3408 sqlite3ErrorMsg(pParse, -
3409 "conflicting ON CONFLICT clauses specified", 0);-
3410 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
1
3411 if( pIdx->onError==OE_Default ){
pIdx->onError==11Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-2
3412 pIdx->onError = pIndex->onError;-
3413 }
executed 2 times by 1 test: end of block
Executed by:
  • Self test (438)
2
3414 }
executed 3 times by 1 test: end of block
Executed by:
  • Self test (438)
3
3415 if( idxType==SQLITE_IDXTYPE_PRIMARYKEY ) pIdx->idxType = idxType;
executed 41 times by 1 test: pIdx->idxType = idxType;
Executed by:
  • Self test (438)
idxType==2Description
TRUEevaluated 41 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 25 times by 1 test
Evaluated by:
  • Self test (438)
25-41
3416 goto exit_create_index;
executed 66 times by 1 test: goto exit_create_index;
Executed by:
  • Self test (438)
66
3417 }-
3418 }
executed 548 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (54)
548
3419 }
executed 6687 times by 376 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
6687
3420-
3421 if( !IN_RENAME_OBJECT ){
!(pParse->eParseMode>=2)Description
TRUEevaluated 13015 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 258 times by 1 test
Evaluated by:
  • Self test (438)
258-13015
3422-
3423 /* Link the new Index structure to its table and to the other-
3424 ** in-memory database structures. -
3425 */-
3426 assert( pParse->nErr==0 );-
3427 if( db->init.busy ){
db->init.busyDescription
TRUEevaluated 8948 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 4067 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
4067-8948
3428 Index *p;-
3429 assert( !IN_SPECIAL_PARSE );-
3430 assert( sqlite3SchemaMutexHeld(db, 0, pIndex->pSchema) );-
3431 p = sqlite3HashInsert(&pIndex->pSchema->idxHash, -
3432 pIndex->zName, pIndex);-
3433 if( p ){
pDescription
TRUEnever evaluated
FALSEevaluated 8948 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
0-8948
3434 assert( p==pIndex ); /* Malloc must have failed */-
3435 sqlite3OomFault(db);-
3436 goto exit_create_index;
never executed: goto exit_create_index;
0
3437 }-
3438 db->mDbFlags |= DBFLAG_SchemaChange;-
3439 if( pTblName!=0 ){
pTblName!=0Description
TRUEevaluated 4062 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
FALSEevaluated 4886 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
4062-4886
3440 pIndex->tnum = db->init.newTnum;-
3441 }
executed 4062 times by 24 tests: end of block
Executed by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
4062
3442 }
executed 8948 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
8948
3443-
3444 /* If this is the initial CREATE INDEX statement (or CREATE TABLE if the-
3445 ** index is an implied index for a UNIQUE or PRIMARY KEY constraint) then-
3446 ** emit code to allocate the index rootpage on disk and make an entry for-
3447 ** the index in the sqlite_master table and populate the index with-
3448 ** content. But, do not do this if we are simply reading the sqlite_master-
3449 ** table to parse the schema, or if this index is the PRIMARY KEY index-
3450 ** of a WITHOUT ROWID table.-
3451 **-
3452 ** If pTblName==0 it means this index is generated as an implied PRIMARY KEY-
3453 ** or UNIQUE index in a CREATE TABLE statement. Since the table-
3454 ** has just been created, it contains no data and the index initialization-
3455 ** step can be skipped.-
3456 */-
3457 else if( HasRowid(pTab) || pTblName!=0 ){
(((pTab)->tabF... & 0x0020)==0)Description
TRUEevaluated 3954 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 113 times by 1 test
Evaluated by:
  • Self test (438)
pTblName!=0Description
TRUEevaluated 89 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24 times by 1 test
Evaluated by:
  • Self test (438)
24-3954
3458 Vdbe *v;-
3459 char *zStmt;-
3460 int iMem = ++pParse->nMem;-
3461-
3462 v = sqlite3GetVdbe(pParse);-
3463 if( v==0 ) goto exit_create_index;
never executed: goto exit_create_index;
v==0Description
TRUEnever evaluated
FALSEevaluated 4043 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
0-4043
3464-
3465 sqlite3BeginWriteOperation(pParse, 1, iDb);-
3466-
3467 /* Create the rootpage for the index using CreateIndex. But before-
3468 ** doing so, code a Noop instruction and store its address in -
3469 ** Index.tnum. This is required in case this index is actually a -
3470 ** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In -
3471 ** that case the convertToWithoutRowidTable() routine will replace-
3472 ** the Noop with a Goto to jump over the VDBE code generated below. */-
3473 pIndex->tnum = sqlite3VdbeAddOp0(v, OP_Noop);-
3474 sqlite3VdbeAddOp3(v, OP_CreateBtree, iDb, iMem, BTREE_BLOBKEY);-
3475-
3476 /* Gather the complete text of the CREATE INDEX statement into-
3477 ** the zStmt variable-
3478 */-
3479 if( pStart ){
pStartDescription
TRUEevaluated 2425 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 1618 times by 13 tests
Evaluated by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
1618-2425
3480 int n = (int)(pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;-
3481 if( pName->z[n-1]==';' ) n--;
executed 1320 times by 4 tests: n--;
Executed by:
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
pName->z[n-1]==';'Description
TRUEevaluated 1320 times by 4 tests
Evaluated by:
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
FALSEevaluated 1105 times by 7 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (438)
  • Self test (47)
1105-1320
3482 /* A named index with an explicit CREATE INDEX statement */-
3483 zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",-
3484 onError==OE_None ? "" : " UNIQUE", n, pName->z);-
3485 }else{
executed 2425 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2425
3486 /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */-
3487 /* zStmt = sqlite3MPrintf(""); */-
3488 zStmt = 0;-
3489 }
executed 1618 times by 13 tests: end of block
Executed by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
1618
3490-
3491 /* Add an entry in sqlite_master for this index-
3492 */-
3493 sqlite3NestedParse(pParse, -
3494 "INSERT INTO %Q.%s VALUES('index',%Q,%Q,#%d,%Q);",-
3495 db->aDb[iDb].zDbSName, MASTER_NAME,-
3496 pIndex->zName,-
3497 pTab->zName,-
3498 iMem,-
3499 zStmt-
3500 );-
3501 sqlite3DbFree(db, zStmt);-
3502-
3503 /* Fill the index with data and reparse the schema. Code an OP_Expire-
3504 ** to invalidate all pre-compiled statements.-
3505 */-
3506 if( pTblName ){
pTblNameDescription
TRUEevaluated 2425 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 1618 times by 13 tests
Evaluated by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
1618-2425
3507 sqlite3RefillIndex(pParse, pIndex, iMem);-
3508 sqlite3ChangeCookie(pParse, iDb);-
3509 sqlite3VdbeAddParseSchemaOp(v, iDb,-
3510 sqlite3MPrintf(db, "name='%q' AND type='index'", pIndex->zName));-
3511 sqlite3VdbeAddOp2(v, OP_Expire, 0, 1);-
3512 }
executed 2425 times by 10 tests: end of block
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
2425
3513-
3514 sqlite3VdbeJumpHere(v, pIndex->tnum);-
3515 }
executed 4043 times by 22 tests: end of block
Executed by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
4043
3516 }
executed 13015 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13015
3517-
3518 /* When adding an index to the list of indices for a table, make-
3519 ** sure all indices labeled OE_Replace come after all those labeled-
3520 ** OE_Ignore. This is necessary for the correct constraint check-
3521 ** processing (in sqlite3GenerateConstraintChecks()) as part of-
3522 ** UPDATE and INSERT statements. -
3523 */-
3524 if( db->init.busy || pTblName==0 ){
db->init.busyDescription
TRUEevaluated 8948 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 4325 times by 22 tests
Evaluated by:
  • Self test (100)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (32)
  • Self test (33)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
pTblName==0Description
TRUEevaluated 1801 times by 13 tests
Evaluated by:
  • Self test (100)
  • Self test (32)
  • Self test (33)
  • Self test (438)
  • Self test (91)
  • Self test (92)
  • Self test (93)
  • Self test (94)
  • Self test (95)
  • Self test (96)
  • Self test (97)
  • Self test (98)
  • Self test (99)
FALSEevaluated 2524 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
1801-8948
3525 if( onError!=OE_Replace || pTab->pIndex==0
onError!=5Description
TRUEevaluated 10688 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 61 times by 1 test
Evaluated by:
  • Self test (438)
pTab->pIndex==0Description
TRUEevaluated 47 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
14-10688
3526 || pTab->pIndex->onError==OE_Replace){
pTab->pIndex->onError==5Description
TRUEnever evaluated
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
0-14
3527 pIndex->pNext = pTab->pIndex;-
3528 pTab->pIndex = pIndex;-
3529 }else{
executed 10735 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
10735
3530 Index *pOther = pTab->pIndex;-
3531 while( pOther->pNext && pOther->pNext->onError!=OE_Replace ){
pOther->pNextDescription
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
pOther->pNext->onError!=5Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-14
3532 pOther = pOther->pNext;-
3533 }
executed 6 times by 1 test: end of block
Executed by:
  • Self test (438)
6
3534 pIndex->pNext = pOther->pNext;-
3535 pOther->pNext = pIndex;-
3536 }
executed 14 times by 1 test: end of block
Executed by:
  • Self test (438)
14
3537 pIndex = 0;-
3538 }
executed 10749 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
10749
3539 else if( IN_RENAME_OBJECT ){
(pParse->eParseMode>=2)Description
TRUEevaluated 99 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2425 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
99-2425
3540 assert( pParse->pNewIndex==0 );-
3541 pParse->pNewIndex = pIndex;-
3542 pIndex = 0;-
3543 }
executed 99 times by 1 test: end of block
Executed by:
  • Self test (438)
99
3544-
3545 /* Clean up before exiting */-
3546exit_create_index:
code before this statement executed 13273 times by 394 tests: exit_create_index:
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13273
3547 if( pIndex ) sqlite3FreeIndex(db, pIndex);
executed 2522 times by 10 tests: sqlite3FreeIndex(db, pIndex);
Executed by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
pIndexDescription
TRUEevaluated 2522 times by 10 tests
Evaluated by:
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (46)
  • Self test (47)
FALSEevaluated 10890 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
2522-10890
3548 sqlite3ExprDelete(db, pPIWhere);-
3549 sqlite3ExprListDelete(db, pList);-
3550 sqlite3SrcListDelete(db, pTblName);-
3551 sqlite3DbFree(db, zName);-
3552}
executed 13412 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
13412
3553-
3554/*-
3555** Fill the Index.aiRowEst[] array with default information - information-
3556** to be used when we have not run the ANALYZE command.-
3557**-
3558** aiRowEst[0] is supposed to contain the number of elements in the index.-
3559** Since we do not know, guess 1 million. aiRowEst[1] is an estimate of the-
3560** number of rows in the table that match any particular value of the-
3561** first column of the index. aiRowEst[2] is an estimate of the number-
3562** of rows that match any particular combination of the first 2 columns-
3563** of the index. And so forth. It must always be the case that-
3564*-
3565** aiRowEst[N]<=aiRowEst[N-1]-
3566** aiRowEst[N]>=1-
3567**-
3568** Apart from that, we have little to go on besides intuition as to-
3569** how aiRowEst[] should be initialized. The numbers generated here-
3570** are based on typical values found in actual indices.-
3571*/-
3572void sqlite3DefaultRowEst(Index *pIdx){-
3573 /* 10, 9, 8, 7, 6 */-
3574 LogEst aVal[] = { 33, 32, 30, 28, 26 };-
3575 LogEst *a = pIdx->aiRowLogEst;-
3576 int nCopy = MIN(ArraySize(aVal), pIdx->nKeyCol);
(((int)(sizeof...pIdx->nKeyCol)Description
TRUEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18387 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
28-18387
3577 int i;-
3578-
3579 /* Indexes with default row estimates should not have stat1 data */-
3580 assert( !pIdx->hasStat1 );-
3581-
3582 /* Set the first entry (number of rows in the index) to the estimated -
3583 ** number of rows in the table, or half the number of rows in the table-
3584 ** for a partial index. But do not let the estimate drop below 10. */-
3585 a[0] = pIdx->pTable->nRowLogEst;-
3586 if( pIdx->pPartIdxWhere!=0 ) a[0] -= 10; assert( 10==sqlite3LogEst(2) );
executed 139 times by 1 test: a[0] -= 10;
Executed by:
  • Self test (438)
pIdx->pPartIdxWhere!=0Description
TRUEevaluated 139 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18276 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
139-18276
3587 if( a[0]<33 ) a[0] = 33; assert( 33==sqlite3LogEst(10) );
executed 30 times by 1 test: a[0] = 33;
Executed by:
  • Self test (438)
a[0]<33Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18385 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
30-18385
3588-
3589 /* Estimate that a[1] is 10, a[2] is 9, a[3] is 8, a[4] is 7, a[5] is-
3590 ** 6 and each subsequent value (if any) is 5. */-
3591 memcpy(&a[1], aVal, nCopy*sizeof(LogEst));-
3592 for(i=nCopy+1; i<=pIdx->nKeyCol; i++){
i<=pIdx->nKeyColDescription
TRUEevaluated 2504 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18415 times by 394 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
2504-18415
3593 a[i] = 23; assert( 23==sqlite3LogEst(5) );-
3594 }
executed 2504 times by 1 test: end of block
Executed by:
  • Self test (438)
2504
3595-
3596 assert( 0==sqlite3LogEst(1) );-
3597 if( IsUniqueIndex(pIdx) ) a[pIdx->nKeyCol] = 0;
executed 10517 times by 376 tests: a[pIdx->nKeyCol] = 0;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
((pIdx)->onError!=0)Description
TRUEevaluated 10517 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 7898 times by 24 tests
Evaluated by:
  • Self test
  • Self test (2)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • Self test (3)
  • Self test (35)
  • Self test (36)
  • Self test (42)
  • Self test (43)
  • Self test (438)
  • Self test (44)
  • Self test (45)
  • Self test (46)
  • Self test (47)
  • Self test (53)
  • Self test (57)
  • Self test (58)
  • Self test (74)
  • Self test (86)
  • Self test (87)
  • Self test (88)
7898-10517
3598}
executed 18415 times by 394 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
18415
3599-
3600/*-
3601** This routine will drop an existing named index. This routine-
3602** implements the DROP INDEX statement.-
3603*/-
3604void sqlite3DropIndex(Parse *pParse, SrcList *pName, int ifExists){-
3605 Index *pIndex;-
3606 Vdbe *v;-
3607 sqlite3 *db = pParse->db;-
3608 int iDb;-
3609-
3610 assert( pParse->nErr==0 ); /* Never called with prior errors */-
3611 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEnever evaluated
FALSEevaluated 286 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
0-286
3612 goto exit_drop_index;
never executed: goto exit_drop_index;
0
3613 }-
3614 assert( pName->nSrc==1 );-
3615 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
0!=sqlite3ReadSchema(pParse)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 285 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
1-285
3616 goto exit_drop_index;
executed 1 time by 1 test: goto exit_drop_index;
Executed by:
  • Self test (438)
1
3617 }-
3618 pIndex = sqlite3FindIndex(db, pName->a[0].zName, pName->a[0].zDatabase);-
3619 if( pIndex==0 ){
pIndex==0Description
TRUEevaluated 72 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 213 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
72-213
3620 if( !ifExists ){
!ifExistsDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 49 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
23-49
3621 sqlite3ErrorMsg(pParse, "no such index: %S", pName, 0);-
3622 }else{
executed 23 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
23
3623 sqlite3CodeVerifyNamedSchema(pParse, pName->a[0].zDatabase);-
3624 }
executed 49 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
49
3625 pParse->checkSchema = 1;-
3626 goto exit_drop_index;
executed 72 times by 2 tests: goto exit_drop_index;
Executed by:
  • Self test (438)
  • Self test (47)
72
3627 }-
3628 if( pIndex->idxType!=SQLITE_IDXTYPE_APPDEF ){
pIndex->idxType!=0Description
TRUEevaluated 5 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 208 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
5-208
3629 sqlite3ErrorMsg(pParse, "index associated with UNIQUE "-
3630 "or PRIMARY KEY constraint cannot be dropped", 0);-
3631 goto exit_drop_index;
executed 5 times by 1 test: goto exit_drop_index;
Executed by:
  • Self test (438)
5
3632 }-
3633 iDb = sqlite3SchemaToIndex(db, pIndex->pSchema);-
3634#ifndef SQLITE_OMIT_AUTHORIZATION-
3635 {-
3636 int code = SQLITE_DROP_INDEX;-
3637 Table *pTab = pIndex->pTable;-
3638 const char *zDb = db->aDb[iDb].zDbSName;-
3639 const char *zTab = SCHEMA_TABLE(iDb);
(iDb==1)Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 200 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
8-200
3640 if( sqlite3AuthCheck(pParse, SQLITE_DELETE, zTab, 0, zDb) ){
sqlite3AuthChe... zTab, 0, zDb)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 204 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4-204
3641 goto exit_drop_index;
executed 4 times by 1 test: goto exit_drop_index;
Executed by:
  • Self test (438)
4
3642 }-
3643 if( !OMIT_TEMPDB && iDb ) code = SQLITE_DROP_TEMP_INDEX;
executed 18 times by 1 test: code = 12;
Executed by:
  • Self test (438)
iDbDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 186 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
18-186
3644 if( sqlite3AuthCheck(pParse, code, pIndex->zName, pTab->zName, zDb) ){
sqlite3AuthChe...b->zName, zDb)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 200 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
4-200
3645 goto exit_drop_index;
executed 4 times by 1 test: goto exit_drop_index;
Executed by:
  • Self test (438)
4
3646 }-
3647 }-
3648#endif-
3649-
3650 /* Generate code to remove the index and from the master table */-
3651 v = sqlite3GetVdbe(pParse);-
3652 if( v ){
vDescription
TRUEevaluated 200 times by 4 tests
Evaluated by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
FALSEnever evaluated
0-200
3653 sqlite3BeginWriteOperation(pParse, 1, iDb);-
3654 sqlite3NestedParse(pParse,-
3655 "DELETE FROM %Q.%s WHERE name=%Q AND type='index'",-
3656 db->aDb[iDb].zDbSName, MASTER_NAME, pIndex->zName-
3657 );-
3658 sqlite3ClearStatTables(pParse, iDb, "idx", pIndex->zName);-
3659 sqlite3ChangeCookie(pParse, iDb);-
3660 destroyRootPage(pParse, pIndex->tnum, iDb);-
3661 sqlite3VdbeAddOp4(v, OP_DropIndex, iDb, 0, 0, pIndex->zName, 0);-
3662 }
executed 200 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
200
3663-
3664exit_drop_index:
code before this statement executed 200 times by 4 tests: exit_drop_index:
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
200
3665 sqlite3SrcListDelete(db, pName);-
3666}
executed 286 times by 4 tests: end of block
Executed by:
  • Self test (24)
  • Self test (28)
  • Self test (438)
  • Self test (47)
286
3667-
3668/*-
3669** pArray is a pointer to an array of objects. Each object in the-
3670** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()-
3671** to extend the array so that there is space for a new object at the end.-
3672**-
3673** When this function is called, *pnEntry contains the current size of-
3674** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes-
3675** in total).-
3676**-
3677** If the realloc() is successful (i.e. if no OOM condition occurs), the-
3678** space allocated for the new object is zeroed, *pnEntry updated to-
3679** reflect the new size of the array and a pointer to the new allocation-
3680** returned. *pIdx is set to the index of the new array entry in this case.-
3681**-
3682** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains-
3683** unchanged and a copy of pArray returned.-
3684*/-
3685void *sqlite3ArrayAllocate(-
3686 sqlite3 *db, /* Connection to notify of malloc failures */-
3687 void *pArray, /* Array of objects. Might be reallocated */-
3688 int szEntry, /* Size of each object in the array */-
3689 int *pnEntry, /* Number of objects currently in use */-
3690 int *pIdx /* Write the index of a new slot here */-
3691){-
3692 char *z;-
3693 int n = *pnEntry;-
3694 if( (n & (n-1))==0 ){
(n & (n-1))==0Description
TRUEevaluated 92992 times by 5 tests
Evaluated by:
  • Self test (103)
  • Self test (104)
  • Self test (34)
  • Self test (438)
  • Self test (47)
FALSEevaluated 8097 times by 1 test
Evaluated by:
  • Self test (438)
8097-92992
3695 int sz = (n==0) ? 1 : 2*n;
(n==0)Description
TRUEevaluated 55704 times by 5 tests
Evaluated by:
  • Self test (103)
  • Self test (104)
  • Self test (34)
  • Self test (438)
  • Self test (47)
FALSEevaluated 37288 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
37288-55704
3696 void *pNew = sqlite3DbRealloc(db, pArray, sz*szEntry);-
3697 if( pNew==0 ){
pNew==0Description
TRUEnever evaluated
FALSEevaluated 92992 times by 5 tests
Evaluated by:
  • Self test (103)
  • Self test (104)
  • Self test (34)
  • Self test (438)
  • Self test (47)
0-92992
3698 *pIdx = -1;-
3699 return pArray;
never executed: return pArray;
0
3700 }-
3701 pArray = pNew;-
3702 }
executed 92992 times by 5 tests: end of block
Executed by:
  • Self test (103)
  • Self test (104)
  • Self test (34)
  • Self test (438)
  • Self test (47)
92992
3703 z = (char*)pArray;-
3704 memset(&z[n * szEntry], 0, szEntry);-
3705 *pIdx = n;-
3706 ++*pnEntry;-
3707 return pArray;
executed 101089 times by 5 tests: return pArray;
Executed by:
  • Self test (103)
  • Self test (104)
  • Self test (34)
  • Self test (438)
  • Self test (47)
101089
3708}-
3709-
3710/*-
3711** Append a new element to the given IdList. Create a new IdList if-
3712** need be.-
3713**-
3714** A new IdList is returned, or NULL if malloc() fails.-
3715*/-
3716IdList *sqlite3IdListAppend(Parse *pParse, IdList *pList, Token *pToken){-
3717 sqlite3 *db = pParse->db;-
3718 int i;-
3719 if( pList==0 ){
pList==0Description
TRUEevaluated 10371 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 13710 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
10371-13710
3720 pList = sqlite3DbMallocZero(db, sizeof(IdList) );-
3721 if( pList==0 ) return 0;
never executed: return 0;
pList==0Description
TRUEnever evaluated
FALSEevaluated 10371 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
0-10371
3722 }
executed 10371 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
10371
3723 pList->a = sqlite3ArrayAllocate(-
3724 db,-
3725 pList->a,-
3726 sizeof(pList->a[0]),-
3727 &pList->nId,-
3728 &i-
3729 );-
3730 if( i<0 ){
i<0Description
TRUEnever evaluated
FALSEevaluated 24081 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
0-24081
3731 sqlite3IdListDelete(db, pList);-
3732 return 0;
never executed: return 0;
0
3733 }-
3734 pList->a[i].zName = sqlite3NameFromToken(db, pToken);-
3735 if( IN_RENAME_OBJECT && pList->a[i].zName ){
(pParse->eParseMode>=2)Description
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 24031 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
pList->a[i].zNameDescription
TRUEevaluated 50 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-24031
3736 sqlite3RenameTokenMap(pParse, (void*)pList->a[i].zName, pToken);-
3737 }
executed 50 times by 1 test: end of block
Executed by:
  • Self test (438)
50
3738 return pList;
executed 24081 times by 2 tests: return pList;
Executed by:
  • Self test (438)
  • Self test (47)
24081
3739}-
3740-
3741/*-
3742** Delete an IdList.-
3743*/-
3744void sqlite3IdListDelete(sqlite3 *db, IdList *pList){-
3745 int i;-
3746 if( pList==0 ) return;
executed 1218053 times by 436 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pList==0Description
TRUEevaluated 1218053 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 11105 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
11105-1218053
3747 for(i=0; i<pList->nId; i++){
i<pList->nIdDescription
TRUEevaluated 25828 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 11105 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
11105-25828
3748 sqlite3DbFree(db, pList->a[i].zName);-
3749 }
executed 25828 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
25828
3750 sqlite3DbFree(db, pList->a);-
3751 sqlite3DbFreeNN(db, pList);-
3752}
executed 11105 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
11105
3753-
3754/*-
3755** Return the index in pList of the identifier named zId. Return -1-
3756** if not found.-
3757*/-
3758int sqlite3IdListIndex(IdList *pList, const char *zName){-
3759 int i;-
3760 if( pList==0 ) return -1;
executed 7875 times by 1 test: return -1;
Executed by:
  • Self test (438)
pList==0Description
TRUEevaluated 7875 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 497 times by 1 test
Evaluated by:
  • Self test (438)
497-7875
3761 for(i=0; i<pList->nId; i++){
i<pList->nIdDescription
TRUEevaluated 571 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 224 times by 1 test
Evaluated by:
  • Self test (438)
224-571
3762 if( sqlite3StrICmp(pList->a[i].zName, zName)==0 ) return i;
executed 273 times by 1 test: return i;
Executed by:
  • Self test (438)
sqlite3StrICmp...ame, zName)==0Description
TRUEevaluated 273 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 298 times by 1 test
Evaluated by:
  • Self test (438)
273-298
3763 }
executed 298 times by 1 test: end of block
Executed by:
  • Self test (438)
298
3764 return -1;
executed 224 times by 1 test: return -1;
Executed by:
  • Self test (438)
224
3765}-
3766-
3767/*-
3768** Expand the space allocated for the given SrcList object by-
3769** creating nExtra new slots beginning at iStart. iStart is zero based.-
3770** New slots are zeroed.-
3771**-
3772** For example, suppose a SrcList initially contains two entries: A,B.-
3773** To append 3 new entries onto the end, do this:-
3774**-
3775** sqlite3SrcListEnlarge(db, pSrclist, 3, 2);-
3776**-
3777** After the call above it would contain: A, B, nil, nil, nil.-
3778** If the iStart argument had been 1 instead of 2, then the result-
3779** would have been: A, nil, nil, nil, B. To prepend the new slots,-
3780** the iStart value would be 0. The result then would-
3781** be: nil, nil, nil, A, B.-
3782**-
3783** If a memory allocation fails the SrcList is unchanged. The-
3784** db->mallocFailed flag will be set to true.-
3785*/-
3786SrcList *sqlite3SrcListEnlarge(-
3787 sqlite3 *db, /* Database connection to notify of OOM errors */-
3788 SrcList *pSrc, /* The SrcList to be enlarged */-
3789 int nExtra, /* Number of new slots to add to pSrc->a[] */-
3790 int iStart /* Index in pSrc->a[] of first new slot */-
3791){-
3792 int i;-
3793-
3794 /* Sanity checking on calling parameters */-
3795 assert( iStart>=0 );-
3796 assert( nExtra>=1 );-
3797 assert( pSrc!=0 );-
3798 assert( iStart<=pSrc->nSrc );-
3799-
3800 /* Allocate additional space if needed */-
3801 if( (u32)pSrc->nSrc+nExtra>pSrc->nAlloc ){
(u32)pSrc->nSr...a>pSrc->nAllocDescription
TRUEevaluated 8700 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 267559 times by 1 test
Evaluated by:
  • Self test (438)
8700-267559
3802 SrcList *pNew;-
3803 int nAlloc = pSrc->nSrc*2+nExtra;-
3804 int nGot;-
3805 pNew = sqlite3DbRealloc(db, pSrc,-
3806 sizeof(*pSrc) + (nAlloc-1)*sizeof(pSrc->a[0]) );-
3807 if( pNew==0 ){
pNew==0Description
TRUEevaluated 6 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 8694 times by 1 test
Evaluated by:
  • Self test (438)
6-8694
3808 assert( db->mallocFailed );-
3809 return pSrc;
executed 6 times by 1 test: return pSrc;
Executed by:
  • Self test (438)
6
3810 }-
3811 pSrc = pNew;-
3812 nGot = (sqlite3DbMallocSize(db, pNew) - sizeof(*pSrc))/sizeof(pSrc->a[0])+1;-
3813 pSrc->nAlloc = nGot;-
3814 }
executed 8694 times by 1 test: end of block
Executed by:
  • Self test (438)
8694
3815-
3816 /* Move existing slots that come after the newly inserted slots-
3817 ** out of the way */-
3818 for(i=pSrc->nSrc-1; i>=iStart; i--){
i>=iStartDescription
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 276253 times by 1 test
Evaluated by:
  • Self test (438)
36-276253
3819 pSrc->a[i+nExtra] = pSrc->a[i];-
3820 }
executed 36 times by 1 test: end of block
Executed by:
  • Self test (438)
36
3821 pSrc->nSrc += nExtra;-
3822-
3823 /* Zero the newly allocated slots */-
3824 memset(&pSrc->a[iStart], 0, sizeof(pSrc->a[0])*nExtra);-
3825 for(i=iStart; i<iStart+nExtra; i++){
i<iStart+nExtraDescription
TRUEevaluated 276267 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 276253 times by 1 test
Evaluated by:
  • Self test (438)
276253-276267
3826 pSrc->a[i].iCursor = -1;-
3827 }
executed 276267 times by 1 test: end of block
Executed by:
  • Self test (438)
276267
3828-
3829 /* Return a pointer to the enlarged SrcList */-
3830 return pSrc;
executed 276253 times by 1 test: return pSrc;
Executed by:
  • Self test (438)
276253
3831}-
3832-
3833-
3834/*-
3835** Append a new table name to the given SrcList. Create a new SrcList if-
3836** need be. A new entry is created in the SrcList even if pTable is NULL.-
3837**-
3838** A SrcList is returned, or NULL if there is an OOM error. The returned-
3839** SrcList might be the same as the SrcList that was input or it might be-
3840** a new one. If an OOM error does occurs, then the prior value of pList-
3841** that is input to this routine is automatically freed.-
3842**-
3843** If pDatabase is not null, it means that the table has an optional-
3844** database name prefix. Like this: "database.table". The pDatabase-
3845** points to the table name and the pTable points to the database name.-
3846** The SrcList.a[].zName field is filled with the table name which might-
3847** come from pTable (if pDatabase is NULL) or from pDatabase. -
3848** SrcList.a[].zDatabase is filled with the database name from pTable,-
3849** or with NULL if no database is specified.-
3850**-
3851** In other words, if call like this:-
3852**-
3853** sqlite3SrcListAppend(D,A,B,0);-
3854**-
3855** Then B is a table name and the database name is unspecified. If called-
3856** like this:-
3857**-
3858** sqlite3SrcListAppend(D,A,B,C);-
3859**-
3860** Then C is the table name and B is the database name. If C is defined-
3861** then so is B. In other words, we never have a case where:-
3862**-
3863** sqlite3SrcListAppend(D,A,0,C);-
3864**-
3865** Both pTable and pDatabase are assumed to be quoted. They are dequoted-
3866** before being added to the SrcList.-
3867*/-
3868SrcList *sqlite3SrcListAppend(-
3869 sqlite3 *db, /* Connection to notify of malloc failures */-
3870 SrcList *pList, /* Append to this SrcList. NULL creates a new SrcList */-
3871 Token *pTable, /* Table to append */-
3872 Token *pDatabase /* Database of the table */-
3873){-
3874 struct SrcList_item *pItem;-
3875 assert( pDatabase==0 || pTable!=0 ); /* Cannot have C without B */-
3876 assert( db!=0 );-
3877 if( pList==0 ){
pList==0Description
TRUEevaluated 298940 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 274738 times by 1 test
Evaluated by:
  • Self test (438)
274738-298940
3878 pList = sqlite3DbMallocRawNN(db, sizeof(SrcList) );-
3879 if( pList==0 ) return 0;
executed 153 times by 1 test: return 0;
Executed by:
  • Self test (438)
pList==0Description
TRUEevaluated 153 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 298787 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
153-298787
3880 pList->nAlloc = 1;-
3881 pList->nSrc = 1;-
3882 memset(&pList->a[0], 0, sizeof(pList->a[0]));-
3883 pList->a[0].iCursor = -1;-
3884 }else{
executed 298787 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
298787
3885 pList = sqlite3SrcListEnlarge(db, pList, 1, pList->nSrc);-
3886 }
executed 274738 times by 1 test: end of block
Executed by:
  • Self test (438)
274738
3887 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 573523 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
2-573523
3888 sqlite3SrcListDelete(db, pList);-
3889 return 0;
executed 2 times by 1 test: return 0;
Executed by:
  • Self test (438)
2
3890 }-
3891 pItem = &pList->a[pList->nSrc-1];-
3892 if( pDatabase && pDatabase->z==0 ){
pDatabaseDescription
TRUEevaluated 471751 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 101772 times by 409 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
pDatabase->z==0Description
TRUEevaluated 383192 times by 69 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
FALSEevaluated 88559 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
88559-471751
3893 pDatabase = 0;-
3894 }
executed 383192 times by 69 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (11)
  • Self test (12)
  • Self test (13)
  • Self test (14)
  • Self test (15)
  • Self test (16)
  • Self test (17)
  • Self test (18)
  • Self test (19)
  • Self test (2)
  • Self test (20)
  • Self test (21)
  • Self test (22)
  • Self test (23)
  • Self test (24)
  • Self test (26)
  • Self test (27)
  • Self test (28)
  • Self test (29)
  • ...
383192
3895 if( pDatabase ){
pDatabaseDescription
TRUEevaluated 88559 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 484964 times by 424 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
88559-484964
3896 pItem->zName = sqlite3NameFromToken(db, pDatabase);-
3897 pItem->zDatabase = sqlite3NameFromToken(db, pTable);-
3898 }else{
executed 88559 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
88559
3899 pItem->zName = sqlite3NameFromToken(db, pTable);-
3900 pItem->zDatabase = 0;-
3901 }
executed 484964 times by 424 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
484964
3902 return pList;
executed 573523 times by 436 tests: return pList;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
573523
3903}-
3904-
3905/*-
3906** Assign VdbeCursor index numbers to all tables in a SrcList-
3907*/-
3908void sqlite3SrcListAssignCursors(Parse *pParse, SrcList *pList){-
3909 int i;-
3910 struct SrcList_item *pItem;-
3911 assert(pList || pParse->db->mallocFailed );-
3912 if( pList ){
pListDescription
TRUEevaluated 1013931 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEnever evaluated
0-1013931
3913 for(i=0, pItem=pList->a; i<pList->nSrc; i++, pItem++){
i<pList->nSrcDescription
TRUEevaluated 922828 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1010511 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
922828-1010511
3914 if( pItem->iCursor>=0 ) break;
executed 3420 times by 2 tests: break;
Executed by:
  • Self test (438)
  • Self test (47)
pItem->iCursor>=0Description
TRUEevaluated 3420 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 919408 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
3420-919408
3915 pItem->iCursor = pParse->nTab++;-
3916 if( pItem->pSelect ){
pItem->pSelectDescription
TRUEevaluated 2690 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 916718 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
2690-916718
3917 sqlite3SrcListAssignCursors(pParse, pItem->pSelect->pSrc);-
3918 }
executed 2690 times by 1 test: end of block
Executed by:
  • Self test (438)
2690
3919 }
executed 919408 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
919408
3920 }
executed 1013931 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1013931
3921}
executed 1013931 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1013931
3922-
3923/*-
3924** Delete an entire SrcList including all its substructure.-
3925*/-
3926void sqlite3SrcListDelete(sqlite3 *db, SrcList *pList){-
3927 int i;-
3928 struct SrcList_item *pItem;-
3929 if( pList==0 ) return;
executed 7075 times by 376 tests: return;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
pList==0Description
TRUEevaluated 7075 times by 376 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
FALSEevaluated 1265071 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
7075-1265071
3930 for(pItem=pList->a, i=0; i<pList->nSrc; i++, pItem++){
i<pList->nSrcDescription
TRUEevaluated 1085568 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 1265071 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1085568-1265071
3931 sqlite3DbFree(db, pItem->zDatabase);-
3932 sqlite3DbFree(db, pItem->zName);-
3933 sqlite3DbFree(db, pItem->zAlias);-
3934 if( pItem->fg.isIndexedBy ) sqlite3DbFree(db, pItem->u1.zIndexedBy);
executed 130 times by 2 tests: sqlite3DbFree(db, pItem->u1.zIndexedBy);
Executed by:
  • Self test (438)
  • Self test (47)
pItem->fg.isIndexedByDescription
TRUEevaluated 130 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 1085438 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
130-1085438
3935 if( pItem->fg.isTabFunc ) sqlite3ExprListDelete(db, pItem->u1.pFuncArg);
executed 8804 times by 1 test: sqlite3ExprListDelete(db, pItem->u1.pFuncArg);
Executed by:
  • Self test (438)
pItem->fg.isTabFuncDescription
TRUEevaluated 8804 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1076764 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
8804-1076764
3936 sqlite3DeleteTable(db, pItem->pTab);-
3937 sqlite3SelectDelete(db, pItem->pSelect);-
3938 sqlite3ExprDelete(db, pItem->pOn);-
3939 sqlite3IdListDelete(db, pItem->pUsing);-
3940 }
executed 1085568 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1085568
3941 sqlite3DbFreeNN(db, pList);-
3942}
executed 1265071 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1265071
3943-
3944/*-
3945** This routine is called by the parser to add a new term to the-
3946** end of a growing FROM clause. The "p" parameter is the part of-
3947** the FROM clause that has already been constructed. "p" is NULL-
3948** if this is the first term of the FROM clause. pTable and pDatabase-
3949** are the name of the table and database named in the FROM clause term.-
3950** pDatabase is NULL if the database name qualifier is missing - the-
3951** usual case. If the term has an alias, then pAlias points to the-
3952** alias token. If the term is a subquery, then pSubquery is the-
3953** SELECT statement that the subquery encodes. The pTable and-
3954** pDatabase parameters are NULL for subqueries. The pOn and pUsing-
3955** parameters are the content of the ON and USING clauses.-
3956**-
3957** Return a new SrcList which encodes is the FROM with the new-
3958** term added.-
3959*/-
3960SrcList *sqlite3SrcListAppendFromTerm(-
3961 Parse *pParse, /* Parsing context */-
3962 SrcList *p, /* The left part of the FROM clause already seen */-
3963 Token *pTable, /* Name of the table to add to the FROM clause */-
3964 Token *pDatabase, /* Name of the database containing pTable */-
3965 Token *pAlias, /* The right-hand side of the AS subexpression */-
3966 Select *pSubquery, /* A subquery used in place of a table name */-
3967 Expr *pOn, /* The ON clause of a join */-
3968 IdList *pUsing /* The USING clause of a join */-
3969){-
3970 struct SrcList_item *pItem;-
3971 sqlite3 *db = pParse->db;-
3972 if( !p && (pOn || pUsing) ){
!pDescription
TRUEevaluated 153879 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 274738 times by 1 test
Evaluated by:
  • Self test (438)
pOnDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 153872 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pUsingDescription
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 153868 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
4-274738
3973 sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s", -
3974 (pOn ? "ON" : "USING")-
3975 );-
3976 goto append_from_error;
executed 11 times by 1 test: goto append_from_error;
Executed by:
  • Self test (438)
11
3977 }-
3978 p = sqlite3SrcListAppend(db, p, pTable, pDatabase);-
3979 if( p==0 ){
p==0Description
TRUEevaluated 36 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 428570 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
36-428570
3980 goto append_from_error;
executed 36 times by 1 test: goto append_from_error;
Executed by:
  • Self test (438)
36
3981 }-
3982 assert( p->nSrc>0 );-
3983 pItem = &p->a[p->nSrc-1];-
3984 assert( (pTable==0)==(pDatabase==0) );-
3985 assert( pItem->zName==0 || pDatabase!=0 );-
3986 if( IN_RENAME_OBJECT && pItem->zName ){
(pParse->eParseMode>=2)Description
TRUEevaluated 216 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 428354 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
pItem->zNameDescription
TRUEevaluated 213 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
3-428354
3987 Token *pToken = (ALWAYS(pDatabase) && pDatabase->z) ? pDatabase : pTable;
(pDatabase)Description
TRUEevaluated 213 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
pDatabase->zDescription
TRUEnever evaluated
FALSEevaluated 213 times by 1 test
Evaluated by:
  • Self test (438)
0-213
3988 sqlite3RenameTokenMap(pParse, pItem->zName, pToken);-
3989 }
executed 213 times by 1 test: end of block
Executed by:
  • Self test (438)
213
3990 assert( pAlias!=0 );-
3991 if( pAlias->n ){
pAlias->nDescription
TRUEevaluated 1046 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 427524 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
1046-427524
3992 pItem->zAlias = sqlite3NameFromToken(db, pAlias);-
3993 }
executed 1046 times by 1 test: end of block
Executed by:
  • Self test (438)
1046
3994 pItem->pSelect = pSubquery;-
3995 pItem->pOn = pOn;-
3996 pItem->pUsing = pUsing;-
3997 return p;
executed 428570 times by 436 tests: return p;
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
428570
3998-
3999 append_from_error:-
4000 assert( p==0 );-
4001 sqlite3ExprDelete(db, pOn);-
4002 sqlite3IdListDelete(db, pUsing);-
4003 sqlite3SelectDelete(db, pSubquery);-
4004 return 0;
executed 47 times by 1 test: return 0;
Executed by:
  • Self test (438)
47
4005}-
4006-
4007/*-
4008** Add an INDEXED BY or NOT INDEXED clause to the most recently added -
4009** element of the source-list passed as the second argument.-
4010*/-
4011void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){-
4012 assert( pIndexedBy!=0 );-
4013 if( p && pIndexedBy->n>0 ){
pDescription
TRUEevaluated 460644 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 47 times by 1 test
Evaluated by:
  • Self test (438)
pIndexedBy->n>0Description
TRUEevaluated 140 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 460504 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
47-460644
4014 struct SrcList_item *pItem;-
4015 assert( p->nSrc>0 );-
4016 pItem = &p->a[p->nSrc-1];-
4017 assert( pItem->fg.notIndexed==0 );-
4018 assert( pItem->fg.isIndexedBy==0 );-
4019 assert( pItem->fg.isTabFunc==0 );-
4020 if( pIndexedBy->n==1 && !pIndexedBy->z ){
pIndexedBy->n==1Description
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 122 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
!pIndexedBy->zDescription
TRUEevaluated 18 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-122
4021 /* A "NOT INDEXED" clause was supplied. See parse.y -
4022 ** construct "indexed_opt" for details. */-
4023 pItem->fg.notIndexed = 1;-
4024 }else{
executed 18 times by 1 test: end of block
Executed by:
  • Self test (438)
18
4025 pItem->u1.zIndexedBy = sqlite3NameFromToken(pParse->db, pIndexedBy);-
4026 pItem->fg.isIndexedBy = 1;-
4027 }
executed 122 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
122
4028 }-
4029}
executed 460691 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
460691
4030-
4031/*-
4032** Add the list of function arguments to the SrcList entry for a-
4033** table-valued-function.-
4034*/-
4035void sqlite3SrcListFuncArgs(Parse *pParse, SrcList *p, ExprList *pList){-
4036 if( p ){
pDescription
TRUEevaluated 8794 times by 1 test
Evaluated by:
  • Self test (438)
FALSEnever evaluated
0-8794
4037 struct SrcList_item *pItem = &p->a[p->nSrc-1];-
4038 assert( pItem->fg.notIndexed==0 );-
4039 assert( pItem->fg.isIndexedBy==0 );-
4040 assert( pItem->fg.isTabFunc==0 );-
4041 pItem->u1.pFuncArg = pList;-
4042 pItem->fg.isTabFunc = 1;-
4043 }else{
executed 8794 times by 1 test: end of block
Executed by:
  • Self test (438)
8794
4044 sqlite3ExprListDelete(pParse->db, pList);-
4045 }
never executed: end of block
0
4046}-
4047-
4048/*-
4049** When building up a FROM clause in the parser, the join operator-
4050** is initially attached to the left operand. But the code generator-
4051** expects the join operator to be on the right operand. This routine-
4052** Shifts all join operators from left to right for an entire FROM-
4053** clause.-
4054**-
4055** Example: Suppose the join is like this:-
4056**-
4057** A natural cross join B-
4058**-
4059** The operator is "natural cross join". The A and B operands are stored-
4060** in p->a[0] and p->a[1], respectively. The parser initially stores the-
4061** operator with A. This routine shifts that operator over to B.-
4062*/-
4063void sqlite3SrcListShiftJoinType(SrcList *p){-
4064 if( p ){
pDescription
TRUEevaluated 153736 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 45 times by 1 test
Evaluated by:
  • Self test (438)
45-153736
4065 int i;-
4066 for(i=p->nSrc-1; i>0; i--){
i>0Description
TRUEevaluated 274736 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 153736 times by 436 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
153736-274736
4067 p->a[i].fg.jointype = p->a[i-1].fg.jointype;-
4068 }
executed 274736 times by 1 test: end of block
Executed by:
  • Self test (438)
274736
4069 p->a[0].fg.jointype = 0;-
4070 }
executed 153736 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
153736
4071}
executed 153781 times by 436 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
153781
4072-
4073/*-
4074** Generate VDBE code for a BEGIN statement.-
4075*/-
4076void sqlite3BeginTransaction(Parse *pParse, int type){-
4077 sqlite3 *db;-
4078 Vdbe *v;-
4079 int i;-
4080-
4081 assert( pParse!=0 );-
4082 db = pParse->db;-
4083 assert( db!=0 );-
4084 if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION, "BEGIN", 0, 0) ){
sqlite3AuthChe..."BEGIN", 0, 0)Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2830 times by 52 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (34)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (49)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (54)
  • ...
1-2830
4085 return;
executed 1 time by 1 test: return;
Executed by:
  • Self test (438)
1
4086 }-
4087 v = sqlite3GetVdbe(pParse);-
4088 if( !v ) return;
executed 2 times by 1 test: return;
Executed by:
  • Self test (438)
!vDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2828 times by 52 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (34)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (49)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (54)
  • ...
2-2828
4089 if( type!=TK_DEFERRED ){
type!=7Description
TRUEevaluated 119 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2709 times by 52 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (34)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (49)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (54)
  • ...
119-2709
4090 for(i=0; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 242 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 119 times by 1 test
Evaluated by:
  • Self test (438)
119-242
4091 sqlite3VdbeAddOp2(v, OP_Transaction, i, (type==TK_EXCLUSIVE)+1);-
4092 sqlite3VdbeUsesBtree(v, i);-
4093 }
executed 242 times by 1 test: end of block
Executed by:
  • Self test (438)
242
4094 }
executed 119 times by 1 test: end of block
Executed by:
  • Self test (438)
119
4095 sqlite3VdbeAddOp0(v, OP_AutoCommit);-
4096}
executed 2828 times by 52 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (34)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (49)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (54)
  • ...
2828
4097-
4098/*-
4099** Generate VDBE code for a COMMIT or ROLLBACK statement.-
4100** Code for ROLLBACK is generated if eType==TK_ROLLBACK. Otherwise-
4101** code is generated for a COMMIT.-
4102*/-
4103void sqlite3EndTransaction(Parse *pParse, int eType){-
4104 Vdbe *v;-
4105 int isRollback;-
4106-
4107 assert( pParse!=0 );-
4108 assert( pParse->db!=0 );-
4109 assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );-
4110 isRollback = eType==TK_ROLLBACK;-
4111 if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION,
sqlite3AuthChe...COMMIT", 0, 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1915 times by 44 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (6)
  • Self test (62)
  • Self test (63)
  • Self test (64)
  • ...
4-1915
4112 isRollback ? "ROLLBACK" : "COMMIT", 0, 0) ){
sqlite3AuthChe...COMMIT", 0, 0)Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1915 times by 44 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (6)
  • Self test (62)
  • Self test (63)
  • Self test (64)
  • ...
4-1915
4113 return;
executed 4 times by 1 test: return;
Executed by:
  • Self test (438)
4
4114 }-
4115 v = sqlite3GetVdbe(pParse);-
4116 if( v ){
vDescription
TRUEevaluated 1913 times by 44 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (6)
  • Self test (62)
  • Self test (63)
  • Self test (64)
  • ...
FALSEevaluated 2 times by 1 test
Evaluated by:
  • Self test (438)
2-1913
4117 sqlite3VdbeAddOp2(v, OP_AutoCommit, 1, isRollback);-
4118 }
executed 1913 times by 44 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (6)
  • Self test (62)
  • Self test (63)
  • Self test (64)
  • ...
1913
4119}
executed 1915 times by 44 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (12)
  • Self test (14)
  • Self test (16)
  • Self test (18)
  • Self test (20)
  • Self test (22)
  • Self test (3)
  • Self test (30)
  • Self test (31)
  • Self test (35)
  • Self test (38)
  • Self test (4)
  • Self test (42)
  • Self test (438)
  • Self test (44)
  • Self test (5)
  • Self test (50)
  • Self test (51)
  • Self test (6)
  • Self test (62)
  • Self test (63)
  • Self test (64)
  • ...
1915
4120-
4121/*-
4122** This function is called by the parser when it parses a command to create,-
4123** release or rollback an SQL savepoint. -
4124*/-
4125void sqlite3Savepoint(Parse *pParse, int op, Token *pName){-
4126 char *zName = sqlite3NameFromToken(pParse->db, pName);-
4127 if( zName ){
zNameDescription
TRUEevaluated 35037 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (64)
FALSEnever evaluated
0-35037
4128 Vdbe *v = sqlite3GetVdbe(pParse);-
4129#ifndef SQLITE_OMIT_AUTHORIZATION-
4130 static const char * const az[] = { "BEGIN", "RELEASE", "ROLLBACK" };-
4131 assert( !SAVEPOINT_BEGIN && SAVEPOINT_RELEASE==1 && SAVEPOINT_ROLLBACK==2 );-
4132#endif-
4133 if( !v || sqlite3AuthCheck(pParse, SQLITE_SAVEPOINT, az[op], zName, 0) ){
!vDescription
TRUEnever evaluated
FALSEevaluated 35037 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (64)
sqlite3AuthChe...op], zName, 0)Description
TRUEevaluated 3 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 35034 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (64)
0-35037
4134 sqlite3DbFree(pParse->db, zName);-
4135 return;
executed 3 times by 1 test: return;
Executed by:
  • Self test (438)
3
4136 }-
4137 sqlite3VdbeAddOp4(v, OP_Savepoint, op, 0, 0, zName, P4_DYNAMIC);-
4138 }
executed 35034 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (64)
35034
4139}
executed 35034 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (64)
35034
4140-
4141/*-
4142** Make sure the TEMP database is open and available for use. Return-
4143** the number of errors. Leave any error messages in the pParse structure.-
4144*/-
4145int sqlite3OpenTempDatabase(Parse *pParse){-
4146 sqlite3 *db = pParse->db;-
4147 if( db->aDb[1].pBt==0 && !pParse->explain ){
db->aDb[1].pBt==0Description
TRUEevaluated 2269 times by 12 tests
Evaluated by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
FALSEevaluated 8436 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (53)
!pParse->explainDescription
TRUEevaluated 2268 times by 12 tests
Evaluated by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-8436
4148 int rc;-
4149 Btree *pBt;-
4150 static const int flags = -
4151 SQLITE_OPEN_READWRITE |-
4152 SQLITE_OPEN_CREATE |-
4153 SQLITE_OPEN_EXCLUSIVE |-
4154 SQLITE_OPEN_DELETEONCLOSE |-
4155 SQLITE_OPEN_TEMP_DB;-
4156-
4157 rc = sqlite3BtreeOpen(db->pVfs, 0, db, &pBt, 0, flags);-
4158 if( rc!=SQLITE_OK ){
rc!=0Description
TRUEnever evaluated
FALSEevaluated 2268 times by 12 tests
Evaluated by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
0-2268
4159 sqlite3ErrorMsg(pParse, "unable to open a temporary database "-
4160 "file for storing temporary tables");-
4161 pParse->rc = rc;-
4162 return 1;
never executed: return 1;
0
4163 }-
4164 db->aDb[1].pBt = pBt;-
4165 assert( db->aDb[1].pSchema );-
4166 if( SQLITE_NOMEM==sqlite3BtreeSetPageSize(pBt, db->nextPagesize, -1, 0) ){
7==sqlite3Btre...gesize, -1, 0)Description
TRUEnever evaluated
FALSEevaluated 2268 times by 12 tests
Evaluated by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
0-2268
4167 sqlite3OomFault(db);-
4168 return 1;
never executed: return 1;
0
4169 }-
4170 }
executed 2268 times by 12 tests: end of block
Executed by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
2268
4171 return 0;
executed 10705 times by 12 tests: return 0;
Executed by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
10705
4172}-
4173-
4174/*-
4175** Record the fact that the schema cookie will need to be verified-
4176** for database iDb. The code to actually verify the schema cookie-
4177** will occur at the end of the top-level VDBE and will be generated-
4178** later, by sqlite3FinishCoding().-
4179*/-
4180void sqlite3CodeVerifySchema(Parse *pParse, int iDb){-
4181 Parse *pToplevel = sqlite3ParseToplevel(pParse);
(pParse)->pToplevelDescription
TRUEevaluated 7455 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 456464 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
7455-456464
4182-
4183 assert( iDb>=0 && iDb<pParse->db->nDb );-
4184 assert( pParse->db->aDb[iDb].pBt!=0 || iDb==1 );-
4185 assert( iDb<SQLITE_MAX_ATTACHED+2 );-
4186 assert( sqlite3SchemaMutexHeld(pParse->db, iDb, 0) );-
4187 if( DbMaskTest(pToplevel->cookieMask, iDb)==0 ){
(((pToplevel->...(iDb)))!=0)==0Description
TRUEevaluated 247028 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
FALSEevaluated 216891 times by 382 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • ...
216891-247028
4188 DbMaskSet(pToplevel->cookieMask, iDb);-
4189 if( !OMIT_TEMPDB && iDb==1 ){
iDb==1Description
TRUEevaluated 10633 times by 12 tests
Evaluated by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
FALSEevaluated 236395 times by 435 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
10633-236395
4190 sqlite3OpenTempDatabase(pToplevel);-
4191 }
executed 10633 times by 12 tests: end of block
Executed by:
  • Self test (43)
  • Self test (438)
  • Self test (45)
  • Self test (53)
  • Self test (65)
  • Self test (66)
  • Self test (67)
  • Self test (68)
  • Self test (69)
  • Self test (70)
  • Self test (71)
  • Self test (74)
10633
4192 }
executed 247028 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
247028
4193}
executed 463919 times by 435 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (103)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • ...
463919
4194-
4195/*-
4196** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each -
4197** attached database. Otherwise, invoke it for the database named zDb only.-
4198*/-
4199void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){-
4200 sqlite3 *db = pParse->db;-
4201 int i;-
4202 for(i=0; i<db->nDb; i++){
i<db->nDbDescription
TRUEevaluated 746 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 348 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
348-746
4203 Db *pDb = &db->aDb[i];-
4204 if( pDb->pBt && (!zDb || 0==sqlite3StrICmp(zDb, pDb->zDbSName)) ){
pDb->pBtDescription
TRUEevaluated 432 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 314 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
!zDbDescription
TRUEevaluated 348 times by 2 tests
Evaluated by:
  • Self test (438)
  • Self test (47)
FALSEevaluated 84 times by 1 test
Evaluated by:
  • Self test (438)
0==sqlite3StrI...pDb->zDbSName)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 59 times by 1 test
Evaluated by:
  • Self test (438)
25-432
4205 sqlite3CodeVerifySchema(pParse, i);-
4206 }
executed 373 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
373
4207 }
executed 746 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
746
4208}
executed 348 times by 2 tests: end of block
Executed by:
  • Self test (438)
  • Self test (47)
348
4209-
4210/*-
4211** Generate VDBE code that prepares for doing an operation that-
4212** might change the database.-
4213**-
4214** This routine starts a new transaction if we are not already within-
4215** a transaction. If we are already within a transaction, then a checkpoint-
4216** is set if the setStatement parameter is true. A checkpoint should-
4217** be set for operations that might fail (due to a constraint) part of-
4218** the way through and which will need to undo some writes without having to-
4219** rollback the whole transaction. For operations where all constraints-
4220** can be checked before any changes are made to the database, it is never-
4221** necessary to undo a write and the checkpoint should not be set.-
4222*/-
4223void sqlite3BeginWriteOperation(Parse *pParse, int setStatement, int iDb){-
4224 Parse *pToplevel = sqlite3ParseToplevel(pParse);
(pParse)->pToplevelDescription
TRUEevaluated 6680 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 155179 times by 407 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
6680-155179
4225 sqlite3CodeVerifySchema(pParse, iDb);-
4226 DbMaskSet(pToplevel->writeMask, iDb);-
4227 pToplevel->isMultiWrite |= setStatement;-
4228}
executed 161859 times by 407 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (101)
  • Self test (104)
  • Self test (105)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • ...
161859
4229-
4230/*-
4231** Indicate that the statement currently under construction might write-
4232** more than one entry (example: deleting one row then inserting another,-
4233** inserting multiple rows in a table, or inserting a row and index entries.)-
4234** If an abort occurs after some of these writes have completed, then it will-
4235** be necessary to undo the completed writes.-
4236*/-
4237void sqlite3MultiWrite(Parse *pParse){-
4238 Parse *pToplevel = sqlite3ParseToplevel(pParse);
(pParse)->pToplevelDescription
TRUEevaluated 288 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 18328 times by 360 tests
Evaluated by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • ...
288-18328
4239 pToplevel->isMultiWrite = 1;-
4240}
executed 18616 times by 360 tests: end of block
Executed by:
  • Self test (10)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • Self test (127)
  • Self test (128)
  • ...
18616
4241-
4242/* -
4243** The code generator calls this routine if is discovers that it is-
4244** possible to abort a statement prior to completion. In order to -
4245** perform this abort without corrupting the database, we need to make-
4246** sure that the statement is protected by a statement transaction.-
4247**-
4248** Technically, we only need to set the mayAbort flag if the-
4249** isMultiWrite flag was previously set. There is a time dependency-
4250** such that the abort must occur after the multiwrite. This makes-
4251** some statements involving the REPLACE conflict resolution algorithm-
4252** go a little faster. But taking advantage of this time dependency-
4253** makes it more difficult to prove that the code is correct (in -
4254** particular, it prevents us from writing an effective-
4255** implementation of sqlite3AssertMayAbort()) and so we have chosen-
4256** to take the safe route and skip the optimization.-
4257*/-
4258void sqlite3MayAbort(Parse *pParse){-
4259 Parse *pToplevel = sqlite3ParseToplevel(pParse);
(pParse)->pToplevelDescription
TRUEevaluated 1091 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 26722 times by 371 tests
Evaluated by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
1091-26722
4260 pToplevel->mayAbort = 1;-
4261}
executed 27813 times by 371 tests: end of block
Executed by:
  • Self test
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • ...
27813
4262-
4263/*-
4264** Code an OP_Halt that causes the vdbe to return an SQLITE_CONSTRAINT-
4265** error. The onError parameter determines which (if any) of the statement-
4266** and/or current transaction is rolled back.-
4267*/-
4268void sqlite3HaltConstraint(-
4269 Parse *pParse, /* Parsing context */-
4270 int errCode, /* extended error code */-
4271 int onError, /* Constraint type */-
4272 char *p4, /* Error message */-
4273 i8 p4type, /* P4_STATIC or P4_TRANSIENT */-
4274 u8 p5Errmsg /* P5_ErrMsg type */-
4275){-
4276 Vdbe *v = sqlite3GetVdbe(pParse);-
4277 assert( (errCode&0xff)==SQLITE_CONSTRAINT );-
4278 if( onError==OE_Abort ){
onError==2Description
TRUEevaluated 13764 times by 365 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 254 times by 1 test
Evaluated by:
  • Self test (438)
254-13764
4279 sqlite3MayAbort(pParse);-
4280 }
executed 13764 times by 365 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
13764
4281 sqlite3VdbeAddOp4(v, OP_Halt, errCode, onError, 0, p4, p4type);-
4282 sqlite3VdbeChangeP5(v, p5Errmsg);-
4283}
executed 14018 times by 365 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
14018
4284-
4285/*-
4286** Code an OP_Halt due to UNIQUE or PRIMARY KEY constraint violation.-
4287*/-
4288void sqlite3UniqueConstraint(-
4289 Parse *pParse, /* Parsing context */-
4290 int onError, /* Constraint type */-
4291 Index *pIdx /* The index that triggers the constraint */-
4292){-
4293 char *zErr;-
4294 int j;-
4295 StrAccum errMsg;-
4296 Table *pTab = pIdx->pTable;-
4297-
4298 sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);-
4299 if( pIdx->aColExpr ){
pIdx->aColExprDescription
TRUEevaluated 34 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10677 times by 365 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
34-10677
4300 sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName);-
4301 }else{
executed 34 times by 1 test: end of block
Executed by:
  • Self test (438)
34
4302 for(j=0; j<pIdx->nKeyCol; j++){
j<pIdx->nKeyColDescription
TRUEevaluated 11627 times by 365 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 10677 times by 365 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
10677-11627
4303 char *zCol;-
4304 assert( pIdx->aiColumn[j]>=0 );-
4305 zCol = pTab->aCol[pIdx->aiColumn[j]].zName;-
4306 if( j ) sqlite3_str_append(&errMsg, ", ", 2);
executed 950 times by 3 tests: sqlite3_str_append(&errMsg, ", ", 2);
Executed by:
  • Self test (32)
  • Self test (33)
  • Self test (438)
jDescription
TRUEevaluated 950 times by 3 tests
Evaluated by:
  • Self test (32)
  • Self test (33)
  • Self test (438)
FALSEevaluated 10677 times by 365 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
950-10677
4307 sqlite3_str_appendall(&errMsg, pTab->zName);-
4308 sqlite3_str_append(&errMsg, ".", 1);-
4309 sqlite3_str_appendall(&errMsg, zCol);-
4310 }
executed 11627 times by 365 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
11627
4311 }
executed 10677 times by 365 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
10677
4312 zErr = sqlite3StrAccumFinish(&errMsg);-
4313 sqlite3HaltConstraint(pParse, -
4314 IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY -
4315 : SQLITE_CONSTRAINT_UNIQUE,-
4316 onError, zErr, P4_DYNAMIC, P5_ConstraintUnique);-
4317}
executed 10711 times by 365 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
10711
4318-
4319-
4320/*-
4321** Code an OP_Halt due to non-unique rowid.-
4322*/-
4323void sqlite3RowidConstraint(-
4324 Parse *pParse, /* Parsing context */-
4325 int onError, /* Conflict resolution algorithm */-
4326 Table *pTab /* The table with the non-unique rowid */ -
4327){-
4328 char *zMsg;-
4329 int rc;-
4330 if( pTab->iPKey>=0 ){
pTab->iPKey>=0Description
TRUEevaluated 2034 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 664 times by 1 test
Evaluated by:
  • Self test (438)
664-2034
4331 zMsg = sqlite3MPrintf(pParse->db, "%s.%s", pTab->zName,-
4332 pTab->aCol[pTab->iPKey].zName);-
4333 rc = SQLITE_CONSTRAINT_PRIMARYKEY;-
4334 }else{
executed 2034 times by 1 test: end of block
Executed by:
  • Self test (438)
2034
4335 zMsg = sqlite3MPrintf(pParse->db, "%s.rowid", pTab->zName);-
4336 rc = SQLITE_CONSTRAINT_ROWID;-
4337 }
executed 664 times by 1 test: end of block
Executed by:
  • Self test (438)
664
4338 sqlite3HaltConstraint(pParse, rc, onError, zMsg, P4_DYNAMIC,-
4339 P5_ConstraintUnique);-
4340}
executed 2698 times by 1 test: end of block
Executed by:
  • Self test (438)
2698
4341-
4342/*-
4343** Check to see if pIndex uses the collating sequence pColl. Return-
4344** true if it does and false if it does not.-
4345*/-
4346#ifndef SQLITE_OMIT_REINDEX-
4347static int collationMatch(const char *zColl, Index *pIndex){-
4348 int i;-
4349 assert( zColl!=0 );-
4350 for(i=0; i<pIndex->nColumn; i++){
i<pIndex->nColumnDescription
TRUEevaluated 83 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
28-83
4351 const char *z = pIndex->azColl[i];-
4352 assert( z!=0 || pIndex->aiColumn[i]<0 );-
4353 if( pIndex->aiColumn[i]>=0 && 0==sqlite3StrICmp(z, zColl) ){
pIndex->aiColumn[i]>=0Description
TRUEevaluated 55 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
0==sqlite3StrICmp(z, zColl)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test (438)
25-55
4354 return 1;
executed 25 times by 1 test: return 1;
Executed by:
  • Self test (438)
25
4355 }-
4356 }
executed 58 times by 1 test: end of block
Executed by:
  • Self test (438)
58
4357 return 0;
executed 28 times by 1 test: return 0;
Executed by:
  • Self test (438)
28
4358}-
4359#endif-
4360-
4361/*-
4362** Recompute all indices of pTab that use the collating sequence pColl.-
4363** If pColl==0 then recompute all indices of pTab.-
4364*/-
4365#ifndef SQLITE_OMIT_REINDEX-
4366static void reindexTable(Parse *pParse, Table *pTab, char const *zColl){-
4367 Index *pIndex; /* An index associated with pTab */-
4368-
4369 for(pIndex=pTab->pIndex; pIndex; pIndex=pIndex->pNext){
pIndexDescription
TRUEevaluated 226 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 170 times by 1 test
Evaluated by:
  • Self test (438)
170-226
4370 if( zColl==0 || collationMatch(zColl, pIndex) ){
zColl==0Description
TRUEevaluated 173 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 53 times by 1 test
Evaluated by:
  • Self test (438)
collationMatch(zColl, pIndex)Description
TRUEevaluated 25 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 28 times by 1 test
Evaluated by:
  • Self test (438)
25-173
4371 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);-
4372 sqlite3BeginWriteOperation(pParse, 0, iDb);-
4373 sqlite3RefillIndex(pParse, pIndex, -1);-
4374 }
executed 198 times by 1 test: end of block
Executed by:
  • Self test (438)
198
4375 }
executed 226 times by 1 test: end of block
Executed by:
  • Self test (438)
226
4376}
executed 170 times by 1 test: end of block
Executed by:
  • Self test (438)
170
4377#endif-
4378-
4379/*-
4380** Recompute all indices of all tables in all databases where the-
4381** indices use the collating sequence pColl. If pColl==0 then recompute-
4382** all indices everywhere.-
4383*/-
4384#ifndef SQLITE_OMIT_REINDEX-
4385static void reindexDatabases(Parse *pParse, char const *zColl){-
4386 Db *pDb; /* A single database */-
4387 int iDb; /* The database index number */-
4388 sqlite3 *db = pParse->db; /* The database connection */-
4389 HashElem *k; /* For looping over tables in pDb */-
4390 Table *pTab; /* A table in the database */-
4391-
4392 assert( sqlite3BtreeHoldsAllMutexes(db) ); /* Needed for schema access */-
4393 for(iDb=0, pDb=db->aDb; iDb<db->nDb; iDb++, pDb++){
iDb<db->nDbDescription
TRUEevaluated 76 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 36 times by 1 test
Evaluated by:
  • Self test (438)
36-76
4394 assert( pDb!=0 );-
4395 for(k=sqliteHashFirst(&pDb->pSchema->tblHash); k; k=sqliteHashNext(k)){
kDescription
TRUEevaluated 156 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 76 times by 1 test
Evaluated by:
  • Self test (438)
76-156
4396 pTab = (Table*)sqliteHashData(k);-
4397 reindexTable(pParse, pTab, zColl);-
4398 }
executed 156 times by 1 test: end of block
Executed by:
  • Self test (438)
156
4399 }
executed 76 times by 1 test: end of block
Executed by:
  • Self test (438)
76
4400}
executed 36 times by 1 test: end of block
Executed by:
  • Self test (438)
36
4401#endif-
4402-
4403/*-
4404** Generate code for the REINDEX command.-
4405**-
4406** REINDEX -- 1-
4407** REINDEX <collation> -- 2-
4408** REINDEX ?<database>.?<tablename> -- 3-
4409** REINDEX ?<database>.?<indexname> -- 4-
4410**-
4411** Form 1 causes all indices in all attached databases to be rebuilt.-
4412** Form 2 rebuilds all indices in all databases that use the named-
4413** collating function. Forms 3 and 4 rebuild the named index or all-
4414** indices associated with the named table.-
4415*/-
4416#ifndef SQLITE_OMIT_REINDEX-
4417void sqlite3Reindex(Parse *pParse, Token *pName1, Token *pName2){-
4418 CollSeq *pColl; /* Collating sequence to be reindexed, or NULL */-
4419 char *z; /* Name of a table or index */-
4420 const char *zDb; /* Name of the database */-
4421 Table *pTab; /* A table in the database */-
4422 Index *pIndex; /* An index associated with pTab */-
4423 int iDb; /* The database index number */-
4424 sqlite3 *db = pParse->db; /* The database connection */-
4425 Token *pObjName; /* Name of the table or index to be reindexed */-
4426-
4427 /* Read the database schema. If an error occurs, leave an error message-
4428 ** and code in pParse and return NULL. */-
4429 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
0!=sqlite3ReadSchema(pParse)Description
TRUEnever evaluated
FALSEevaluated 63 times by 1 test
Evaluated by:
  • Self test (438)
0-63
4430 return;
never executed: return;
0
4431 }-
4432-
4433 if( pName1==0 ){
pName1==0Description
TRUEevaluated 21 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test (438)
21-42
4434 reindexDatabases(pParse, 0);-
4435 return;
executed 21 times by 1 test: return;
Executed by:
  • Self test (438)
21
4436 }else if( NEVER(pName2==0) || pName2->z==0 ){
(pName2==0)Description
TRUEnever evaluated
FALSEevaluated 42 times by 1 test
Evaluated by:
  • Self test (438)
pName2->z==0Description
TRUEevaluated 30 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
0-42
4437 char *zColl;-
4438 assert( pName1->z );-
4439 zColl = sqlite3NameFromToken(pParse->db, pName1);-
4440 if( !zColl ) return;
never executed: return;
!zCollDescription
TRUEnever evaluated
FALSEevaluated 30 times by 1 test
Evaluated by:
  • Self test (438)
0-30
4441 pColl = sqlite3FindCollSeq(db, ENC(db), zColl, 0);-
4442 if( pColl ){
pCollDescription
TRUEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 15 times by 1 test
Evaluated by:
  • Self test (438)
15
4443 reindexDatabases(pParse, zColl);-
4444 sqlite3DbFree(db, zColl);-
4445 return;
executed 15 times by 1 test: return;
Executed by:
  • Self test (438)
15
4446 }-
4447 sqlite3DbFree(db, zColl);-
4448 }
executed 15 times by 1 test: end of block
Executed by:
  • Self test (438)
15
4449 iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pObjName);-
4450 if( iDb<0 ) return;
never executed: return;
iDb<0Description
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
0-27
4451 z = sqlite3NameFromToken(db, pObjName);-
4452 if( z==0 ) return;
never executed: return;
z==0Description
TRUEnever evaluated
FALSEevaluated 27 times by 1 test
Evaluated by:
  • Self test (438)
0-27
4453 zDb = db->aDb[iDb].zDbSName;-
4454 pTab = sqlite3FindTable(db, z, zDb);-
4455 if( pTab ){
pTabDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 13 times by 1 test
Evaluated by:
  • Self test (438)
13-14
4456 reindexTable(pParse, pTab, 0);-
4457 sqlite3DbFree(db, z);-
4458 return;
executed 14 times by 1 test: return;
Executed by:
  • Self test (438)
14
4459 }-
4460 pIndex = sqlite3FindIndex(db, z, zDb);-
4461 sqlite3DbFree(db, z);-
4462 if( pIndex ){
pIndexDescription
TRUEevaluated 12 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
1-12
4463 sqlite3BeginWriteOperation(pParse, 0, iDb);-
4464 sqlite3RefillIndex(pParse, pIndex, -1);-
4465 return;
executed 12 times by 1 test: return;
Executed by:
  • Self test (438)
12
4466 }-
4467 sqlite3ErrorMsg(pParse, "unable to identify the object to be reindexed");-
4468}
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
1
4469#endif-
4470-
4471/*-
4472** Return a KeyInfo structure that is appropriate for the given Index.-
4473**-
4474** The caller should invoke sqlite3KeyInfoUnref() on the returned object-
4475** when it has finished using it.-
4476*/-
4477KeyInfo *sqlite3KeyInfoOfIndex(Parse *pParse, Index *pIdx){-
4478 int i;-
4479 int nCol = pIdx->nColumn;-
4480 int nKey = pIdx->nKeyCol;-
4481 KeyInfo *pKey;-
4482 if( pParse->nErr ) return 0;
executed 8 times by 1 test: return 0;
Executed by:
  • Self test (438)
pParse->nErrDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 63760 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
8-63760
4483 if( pIdx->uniqNotNull ){
pIdx->uniqNotNullDescription
TRUEevaluated 8449 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 55311 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
8449-55311
4484 pKey = sqlite3KeyInfoAlloc(pParse->db, nKey, nCol-nKey);-
4485 }else{
executed 8449 times by 1 test: end of block
Executed by:
  • Self test (438)
8449
4486 pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);-
4487 }
executed 55311 times by 389 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
55311
4488 if( pKey ){
pKeyDescription
TRUEevaluated 63756 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 4 times by 1 test
Evaluated by:
  • Self test (438)
4-63756
4489 assert( sqlite3KeyInfoIsWriteable(pKey) );-
4490 for(i=0; i<nCol; i++){
i<nColDescription
TRUEevaluated 150107 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 63756 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
63756-150107
4491 const char *zColl = pIdx->azColl[i];-
4492 pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
zColl==sqlite3StrBINARYDescription
TRUEevaluated 145791 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
FALSEevaluated 4316 times by 1 test
Evaluated by:
  • Self test (438)
4316-145791
4493 sqlite3LocateCollSeq(pParse, zColl);-
4494 pKey->aSortOrder[i] = pIdx->aSortOrder[i];-
4495 }
executed 150107 times by 389 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
150107
4496 if( pParse->nErr ){
pParse->nErrDescription
TRUEevaluated 19 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 63737 times by 389 tests
Evaluated by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
19-63737
4497 assert( pParse->rc==SQLITE_ERROR_MISSING_COLLSEQ );-
4498 if( pIdx->bNoQuery==0 ){
pIdx->bNoQuery==0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 11 times by 1 test
Evaluated by:
  • Self test (438)
8-11
4499 /* Deactivate the index because it contains an unknown collating-
4500 ** sequence. The only way to reactive the index is to reload the-
4501 ** schema. Adding the missing collating sequence later does not-
4502 ** reactive the index. The application had the chance to register-
4503 ** the missing index using the collation-needed callback. For-
4504 ** simplicity, SQLite will not give the application a second chance.-
4505 */-
4506 pIdx->bNoQuery = 1;-
4507 pParse->rc = SQLITE_ERROR_RETRY;-
4508 }
executed 8 times by 1 test: end of block
Executed by:
  • Self test (438)
8
4509 sqlite3KeyInfoUnref(pKey);-
4510 pKey = 0;-
4511 }
executed 19 times by 1 test: end of block
Executed by:
  • Self test (438)
19
4512 }
executed 63756 times by 389 tests: end of block
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
63756
4513 return pKey;
executed 63760 times by 389 tests: return pKey;
Executed by:
  • Self test (10)
  • Self test (100)
  • Self test (106)
  • Self test (107)
  • Self test (108)
  • Self test (109)
  • Self test (11)
  • Self test (110)
  • Self test (111)
  • Self test (112)
  • Self test (113)
  • Self test (114)
  • Self test (115)
  • Self test (116)
  • Self test (117)
  • Self test (118)
  • Self test (119)
  • Self test (12)
  • Self test (120)
  • Self test (121)
  • Self test (122)
  • Self test (123)
  • Self test (124)
  • Self test (125)
  • Self test (126)
  • ...
63760
4514}-
4515-
4516#ifndef SQLITE_OMIT_CTE-
4517/* -
4518** This routine is invoked once per CTE by the parser while parsing a -
4519** WITH clause. -
4520*/-
4521With *sqlite3WithAdd(-
4522 Parse *pParse, /* Parsing context */-
4523 With *pWith, /* Existing WITH clause, or NULL */-
4524 Token *pName, /* Name of the common-table */-
4525 ExprList *pArglist, /* Optional column name list for the table */-
4526 Select *pQuery /* Query used to initialize the table */-
4527){-
4528 sqlite3 *db = pParse->db;-
4529 With *pNew;-
4530 char *zName;-
4531-
4532 /* Check that the CTE name is unique within this WITH clause. If-
4533 ** not, store an error in the Parse structure. */-
4534 zName = sqlite3NameFromToken(pParse->db, pName);-
4535 if( zName && pWith ){
zNameDescription
TRUEevaluated 2146 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 10 times by 1 test
Evaluated by:
  • Self test (438)
pWithDescription
TRUEevaluated 445 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1701 times by 1 test
Evaluated by:
  • Self test (438)
10-2146
4536 int i;-
4537 for(i=0; i<pWith->nCte; i++){
i<pWith->nCteDescription
TRUEevaluated 464 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 445 times by 1 test
Evaluated by:
  • Self test (438)
445-464
4538 if( sqlite3StrICmp(zName, pWith->a[i].zName)==0 ){
sqlite3StrICmp...a[i].zName)==0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 463 times by 1 test
Evaluated by:
  • Self test (438)
1-463
4539 sqlite3ErrorMsg(pParse, "duplicate WITH table name: %s", zName);-
4540 }
executed 1 time by 1 test: end of block
Executed by:
  • Self test (438)
1
4541 }
executed 464 times by 1 test: end of block
Executed by:
  • Self test (438)
464
4542 }
executed 445 times by 1 test: end of block
Executed by:
  • Self test (438)
445
4543-
4544 if( pWith ){
pWithDescription
TRUEevaluated 447 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 1709 times by 1 test
Evaluated by:
  • Self test (438)
447-1709
4545 int nByte = sizeof(*pWith) + (sizeof(pWith->a[1]) * pWith->nCte);-
4546 pNew = sqlite3DbRealloc(db, pWith, nByte);-
4547 }else{
executed 447 times by 1 test: end of block
Executed by:
  • Self test (438)
447
4548 pNew = sqlite3DbMallocZero(db, sizeof(*pWith));-
4549 }
executed 1709 times by 1 test: end of block
Executed by:
  • Self test (438)
1709
4550 assert( (pNew!=0 && zName!=0) || db->mallocFailed );-
4551-
4552 if( db->mallocFailed ){
db->mallocFailedDescription
TRUEevaluated 20 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2136 times by 1 test
Evaluated by:
  • Self test (438)
20-2136
4553 sqlite3ExprListDelete(db, pArglist);-
4554 sqlite3SelectDelete(db, pQuery);-
4555 sqlite3DbFree(db, zName);-
4556 pNew = pWith;-
4557 }else{
executed 20 times by 1 test: end of block
Executed by:
  • Self test (438)
20
4558 pNew->a[pNew->nCte].pSelect = pQuery;-
4559 pNew->a[pNew->nCte].pCols = pArglist;-
4560 pNew->a[pNew->nCte].zName = zName;-
4561 pNew->a[pNew->nCte].zCteErr = 0;-
4562 pNew->nCte++;-
4563 }
executed 2136 times by 1 test: end of block
Executed by:
  • Self test (438)
2136
4564-
4565 return pNew;
executed 2156 times by 1 test: return pNew;
Executed by:
  • Self test (438)
2156
4566}-
4567-
4568/*-
4569** Free the contents of the With object passed as the second argument.-
4570*/-
4571void sqlite3WithDelete(sqlite3 *db, With *pWith){-
4572 if( pWith ){
pWithDescription
TRUEevaluated 2098 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 16 times by 1 test
Evaluated by:
  • Self test (438)
16-2098
4573 int i;-
4574 for(i=0; i<pWith->nCte; i++){
i<pWith->nCteDescription
TRUEevaluated 2560 times by 1 test
Evaluated by:
  • Self test (438)
FALSEevaluated 2098 times by 1 test
Evaluated by:
  • Self test (438)
2098-2560
4575 struct Cte *pCte = &pWith->a[i];-
4576 sqlite3ExprListDelete(db, pCte->pCols);-
4577 sqlite3SelectDelete(db, pCte->pSelect);-
4578 sqlite3DbFree(db, pCte->zName);-
4579 }
executed 2560 times by 1 test: end of block
Executed by:
  • Self test (438)
2560
4580 sqlite3DbFree(db, pWith);-
4581 }
executed 2098 times by 1 test: end of block
Executed by:
  • Self test (438)
2098
4582}
executed 2114 times by 1 test: end of block
Executed by:
  • Self test (438)
2114
4583#endif /* !defined(SQLITE_OMIT_CTE) */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.2