mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Revert whitespace fixes to third_party (#501)
This commit is contained in:
parent
d4000bb8f7
commit
9de3d8f1e6
365 changed files with 39190 additions and 39211 deletions
200
third_party/sqlite3/build.c
vendored
200
third_party/sqlite3/build.c
vendored
|
@ -39,7 +39,7 @@ struct TableLock {
|
|||
};
|
||||
|
||||
/*
|
||||
** Record the fact that we want to lock a table at run-time.
|
||||
** Record the fact that we want to lock a table at run-time.
|
||||
**
|
||||
** The table to be locked has root page iTab and is found in database iDb.
|
||||
** A read or a write lock can be taken depending on isWritelock.
|
||||
|
@ -93,7 +93,7 @@ void sqlite3TableLock(
|
|||
*/
|
||||
static void codeTableLocks(Parse *pParse){
|
||||
int i;
|
||||
Vdbe *pVdbe = pParse->pVdbe;
|
||||
Vdbe *pVdbe = pParse->pVdbe;
|
||||
assert( pVdbe!=0 );
|
||||
|
||||
for(i=0; i<pParse->nTableLock; i++){
|
||||
|
@ -154,7 +154,7 @@ void sqlite3FinishCoding(Parse *pParse){
|
|||
v = sqlite3GetVdbe(pParse);
|
||||
if( v==0 ) pParse->rc = SQLITE_ERROR;
|
||||
}
|
||||
assert( !pParse->isMultiWrite
|
||||
assert( !pParse->isMultiWrite
|
||||
|| sqlite3VdbeAssertMayAbort(v, pParse->mayAbort));
|
||||
if( v ){
|
||||
if( pParse->bReturning ){
|
||||
|
@ -194,7 +194,7 @@ void sqlite3FinishCoding(Parse *pParse){
|
|||
** transaction on each used database and to verify the schema cookie
|
||||
** on each used database.
|
||||
*/
|
||||
if( db->mallocFailed==0
|
||||
if( db->mallocFailed==0
|
||||
&& (DbMaskNonZero(pParse->cookieMask) || pParse->pConstExpr)
|
||||
){
|
||||
int iDb, i;
|
||||
|
@ -224,8 +224,8 @@ void sqlite3FinishCoding(Parse *pParse){
|
|||
pParse->nVtabLock = 0;
|
||||
#endif
|
||||
|
||||
/* Once all the cookies have been verified and transactions opened,
|
||||
** obtain the required table-locks. This is a no-op unless the
|
||||
/* Once all the cookies have been verified and transactions opened,
|
||||
** obtain the required table-locks. This is a no-op unless the
|
||||
** shared-cache feature is enabled.
|
||||
*/
|
||||
codeTableLocks(pParse);
|
||||
|
@ -372,7 +372,7 @@ Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
|
|||
|| sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0
|
||||
|| sqlite3StrICmp(zName+7, &DFLT_SCHEMA_TABLE[7])==0
|
||||
){
|
||||
p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash,
|
||||
p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash,
|
||||
DFLT_TEMP_SCHEMA_TABLE);
|
||||
}
|
||||
}else{
|
||||
|
@ -399,7 +399,7 @@ Table *sqlite3FindTable(sqlite3 *db, const char *zName, const char *zDatabase){
|
|||
if( sqlite3StrICmp(zName+7, &ALT_SCHEMA_TABLE[7])==0 ){
|
||||
p = sqlite3HashFind(&db->aDb[0].pSchema->tblHash, DFLT_SCHEMA_TABLE);
|
||||
}else if( sqlite3StrICmp(zName+7, &ALT_TEMP_SCHEMA_TABLE[7])==0 ){
|
||||
p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash,
|
||||
p = sqlite3HashFind(&db->aDb[1].pSchema->tblHash,
|
||||
DFLT_TEMP_SCHEMA_TABLE);
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +428,7 @@ Table *sqlite3LocateTable(
|
|||
|
||||
/* Read the database schema. If an error occurs, leave an error message
|
||||
** and code in pParse and return NULL. */
|
||||
if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0
|
||||
if( (db->mDbFlags & DBFLAG_SchemaKnownOk)==0
|
||||
&& SQLITE_OK!=sqlite3ReadSchema(pParse)
|
||||
){
|
||||
return 0;
|
||||
|
@ -478,7 +478,7 @@ Table *sqlite3LocateTable(
|
|||
** sqlite3FixSrcList() for details.
|
||||
*/
|
||||
Table *sqlite3LocateTableItem(
|
||||
Parse *pParse,
|
||||
Parse *pParse,
|
||||
u32 flags,
|
||||
SrcItem *p
|
||||
){
|
||||
|
@ -494,7 +494,7 @@ Table *sqlite3LocateTableItem(
|
|||
}
|
||||
|
||||
/*
|
||||
** Locate the in-memory structure that describes
|
||||
** Locate the in-memory structure that describes
|
||||
** a particular index given the name of that index
|
||||
** and the name of the database that contains the index.
|
||||
** Return NULL if not found.
|
||||
|
@ -682,10 +682,10 @@ void sqlite3DeleteColumnNames(sqlite3 *db, Table *pTable){
|
|||
**
|
||||
** This routine just deletes the data structure. It does not unlink
|
||||
** the table data structure from the hash table. But it does destroy
|
||||
** memory structures of the indices and foreign keys associated with
|
||||
** memory structures of the indices and foreign keys associated with
|
||||
** the table.
|
||||
**
|
||||
** The db parameter is optional. It is needed if the Table object
|
||||
** The db parameter is optional. It is needed if the Table object
|
||||
** contains lookaside memory. (Table objects in the schema do not use
|
||||
** lookaside memory, but some ephemeral Table objects do.) Or the
|
||||
** db parameter can be used with db->pnBytesFreed to measure the memory
|
||||
|
@ -697,7 +697,7 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
|
|||
#ifdef SQLITE_DEBUG
|
||||
/* Record the number of outstanding lookaside allocations in schema Tables
|
||||
** prior to doing any free() operations. Since schema Tables do not use
|
||||
** lookaside, this number should not change.
|
||||
** lookaside, this number should not change.
|
||||
**
|
||||
** If malloc has already failed, it may be that it failed while allocating
|
||||
** a Table object that was going to be marked ephemeral. So do not check
|
||||
|
@ -714,7 +714,7 @@ static void SQLITE_NOINLINE deleteTable(sqlite3 *db, Table *pTable){
|
|||
assert( pIndex->pSchema==pTable->pSchema
|
||||
|| (IsVirtual(pTable) && pIndex->idxType!=SQLITE_IDXTYPE_APPDEF) );
|
||||
if( (db==0 || db->pnBytesFreed==0) && !IsVirtual(pTable) ){
|
||||
char *zName = pIndex->zName;
|
||||
char *zName = pIndex->zName;
|
||||
TESTONLY ( Index *pOld = ) sqlite3HashInsert(
|
||||
&pIndex->pSchema->idxHash, zName, 0
|
||||
);
|
||||
|
@ -829,7 +829,7 @@ int sqlite3FindDbName(sqlite3 *db, const char *zName){
|
|||
/*
|
||||
** The token *pName contains the name of a database (either "main" or
|
||||
** "temp" or the name of an attached db). This routine returns the
|
||||
** index of the named database in db->aDb[], or -1 if the named db
|
||||
** index of the named database in db->aDb[], or -1 if the named db
|
||||
** does not exist.
|
||||
*/
|
||||
int sqlite3FindDb(sqlite3 *db, Token *pName){
|
||||
|
@ -845,7 +845,7 @@ int sqlite3FindDb(sqlite3 *db, Token *pName){
|
|||
** pName1 and pName2. If the table name was fully qualified, for example:
|
||||
**
|
||||
** CREATE TABLE xxx.yyy (...);
|
||||
**
|
||||
**
|
||||
** Then pName1 is set to "xxx" and pName2 "yyy". On the other hand if
|
||||
** the table name is not fully qualified, i.e.:
|
||||
**
|
||||
|
@ -999,7 +999,7 @@ i16 sqlite3StorageColumnToTable(Table *pTab, i16 iCol){
|
|||
** The storage column number (0,1,2,....) is the index of the value
|
||||
** as it appears in the record on disk. Or, if the input column is
|
||||
** the N-th virtual column (zero-based) then the storage number is
|
||||
** the number of non-virtual columns in the table plus N.
|
||||
** the number of non-virtual columns in the table plus N.
|
||||
**
|
||||
** The true column number is the index (0,1,2,...) of the column in
|
||||
** the CREATE TABLE statement.
|
||||
|
@ -1090,7 +1090,7 @@ void sqlite3StartTable(
|
|||
iDb = sqlite3TwoPartName(pParse, pName1, pName2, &pName);
|
||||
if( iDb<0 ) return;
|
||||
if( !OMIT_TEMPDB && isTemp && pName2->n>0 && iDb!=1 ){
|
||||
/* If creating a temp table, the name may not be qualified. Unless
|
||||
/* If creating a temp table, the name may not be qualified. Unless
|
||||
** the database name is "temp" anyway. */
|
||||
sqlite3ErrorMsg(pParse, "temporary table name must be unqualified");
|
||||
return;
|
||||
|
@ -1190,7 +1190,7 @@ void sqlite3StartTable(
|
|||
** the schema table. Note in particular that we must go ahead
|
||||
** and allocate the record number for the table entry now. Before any
|
||||
** PRIMARY KEY or UNIQUE keywords are parsed. Those keywords will cause
|
||||
** indices to be created and the table record must come before the
|
||||
** indices to be created and the table record must come before the
|
||||
** indices. Hence, the record number for the table must be allocated
|
||||
** now.
|
||||
*/
|
||||
|
@ -1208,7 +1208,7 @@ void sqlite3StartTable(
|
|||
}
|
||||
#endif
|
||||
|
||||
/* If the file format and encoding in the database have not been set,
|
||||
/* If the file format and encoding in the database have not been set,
|
||||
** set them now.
|
||||
*/
|
||||
reg1 = pParse->regRowid = ++pParse->nMem;
|
||||
|
@ -1396,7 +1396,7 @@ void sqlite3AddColumn(Parse *pParse, Token *pName, Token *pType){
|
|||
pCol->zName = z;
|
||||
pCol->hName = hName;
|
||||
sqlite3ColumnPropertiesFromName(p, pCol);
|
||||
|
||||
|
||||
if( pType->n==0 ){
|
||||
/* If there is no type specified, columns have the default affinity
|
||||
** 'BLOB' with a default size of 4 bytes. */
|
||||
|
@ -1452,11 +1452,11 @@ void sqlite3AddNotNull(Parse *pParse, int onError){
|
|||
** Scan the column type name zType (length nType) and return the
|
||||
** associated affinity type.
|
||||
**
|
||||
** This routine does a case-independent search of zType for the
|
||||
** This routine does a case-independent search of zType for the
|
||||
** substrings in the following table. If one of the substrings is
|
||||
** found, the corresponding affinity is returned. If zType contains
|
||||
** more than one of the substrings, entries toward the top of
|
||||
** the table take priority. For example, if zType is 'BLOBINT',
|
||||
** more than one of the substrings, entries toward the top of
|
||||
** the table take priority. For example, if zType is 'BLOBINT',
|
||||
** SQLITE_AFF_INTEGER is returned.
|
||||
**
|
||||
** Substring | Affinity
|
||||
|
@ -1595,7 +1595,7 @@ void sqlite3AddDefaultValue(
|
|||
|
||||
/*
|
||||
** Backwards Compatibility Hack:
|
||||
**
|
||||
**
|
||||
** Historical versions of SQLite accepted strings as column names in
|
||||
** indexes and PRIMARY KEY constraints and in UNIQUE constraints. Example:
|
||||
**
|
||||
|
@ -1629,11 +1629,11 @@ static void makeColumnPartOfPrimaryKey(Parse *pParse, Column *pCol){
|
|||
sqlite3ErrorMsg(pParse,
|
||||
"generated columns cannot be part of the PRIMARY KEY");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
** Designate the PRIMARY KEY for the table. pList is a list of names
|
||||
** Designate the PRIMARY KEY for the table. pList is a list of names
|
||||
** of columns that form the primary key. If pList is NULL, then the
|
||||
** most recently added column of the table is the primary key.
|
||||
**
|
||||
|
@ -1663,7 +1663,7 @@ void sqlite3AddPrimaryKey(
|
|||
int nTerm;
|
||||
if( pTab==0 ) goto primary_key_exit;
|
||||
if( pTab->tabFlags & TF_HasPrimaryKey ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"table \"%s\" has more than one primary key", pTab->zName);
|
||||
goto primary_key_exit;
|
||||
}
|
||||
|
@ -1746,7 +1746,7 @@ void sqlite3AddCheckConstraint(
|
|||
while( sqlite3Isspace(zEnd[-1]) ){ zEnd--; }
|
||||
t.z = zStart;
|
||||
t.n = (int)(zEnd - t.z);
|
||||
sqlite3ExprListSetName(pParse, pTab->pCheck, &t, 1);
|
||||
sqlite3ExprListSetName(pParse, pTab->pCheck, &t, 1);
|
||||
}
|
||||
}else
|
||||
#endif
|
||||
|
@ -1775,7 +1775,7 @@ void sqlite3AddCollateType(Parse *pParse, Token *pToken){
|
|||
Index *pIdx;
|
||||
sqlite3DbFree(db, p->aCol[i].zColl);
|
||||
p->aCol[i].zColl = zColl;
|
||||
|
||||
|
||||
/* If the column is declared as "<name> PRIMARY KEY COLLATE <type>",
|
||||
** then an index may have been created on this column before the
|
||||
** collation type was added. Correct this if it is the case.
|
||||
|
@ -1866,7 +1866,7 @@ void sqlite3ChangeCookie(Parse *pParse, int iDb){
|
|||
sqlite3 *db = pParse->db;
|
||||
Vdbe *v = pParse->pVdbe;
|
||||
assert( sqlite3SchemaMutexHeld(db, iDb, 0) );
|
||||
sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION,
|
||||
sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_SCHEMA_VERSION,
|
||||
(int)(1+(unsigned)db->aDb[iDb].pSchema->schema_cookie));
|
||||
}
|
||||
|
||||
|
@ -1887,13 +1887,13 @@ static int identLength(const char *z){
|
|||
}
|
||||
|
||||
/*
|
||||
** The first parameter is a pointer to an output buffer. The second
|
||||
** The first parameter is a pointer to an output buffer. The second
|
||||
** parameter is a pointer to an integer that contains the offset at
|
||||
** which to write into the output buffer. This function copies the
|
||||
** nul-terminated string pointed to by the third parameter, zSignedIdent,
|
||||
** to the specified offset in the buffer and updates *pIdx to refer
|
||||
** to the first byte after the last byte written before returning.
|
||||
**
|
||||
**
|
||||
** If the string zSignedIdent consists entirely of alpha-numeric
|
||||
** characters, does not begin with a digit and is not an SQL keyword,
|
||||
** then it is copied to the output buffer exactly as it is. Otherwise,
|
||||
|
@ -1937,7 +1937,7 @@ static char *createTableStmt(sqlite3 *db, Table *p){
|
|||
n += identLength(pCol->zName) + 5;
|
||||
}
|
||||
n += identLength(p->zName);
|
||||
if( n<50 ){
|
||||
if( n<50 ){
|
||||
zSep = "";
|
||||
zSep2 = ",";
|
||||
zEnd = ")";
|
||||
|
@ -1978,10 +1978,10 @@ static char *createTableStmt(sqlite3 *db, Table *p){
|
|||
testcase( pCol->affinity==SQLITE_AFF_NUMERIC );
|
||||
testcase( pCol->affinity==SQLITE_AFF_INTEGER );
|
||||
testcase( pCol->affinity==SQLITE_AFF_REAL );
|
||||
|
||||
|
||||
zType = azType[pCol->affinity - SQLITE_AFF_BLOB];
|
||||
len = sqlite3Strlen30(zType);
|
||||
assert( pCol->affinity==SQLITE_AFF_BLOB
|
||||
assert( pCol->affinity==SQLITE_AFF_BLOB
|
||||
|| pCol->affinity==sqlite3AffinityType(zType, 0) );
|
||||
memcpy(&zStmt[k], zType, len);
|
||||
k += len;
|
||||
|
@ -2087,7 +2087,7 @@ static int isDupColumn(Index *pIdx, int nKey, Index *pPk, int iCol){
|
|||
assert( j!=XN_ROWID && j!=XN_EXPR );
|
||||
for(i=0; i<nKey; i++){
|
||||
assert( pIdx->aiColumn[i]>=0 || j>=0 );
|
||||
if( pIdx->aiColumn[i]==j
|
||||
if( pIdx->aiColumn[i]==j
|
||||
&& sqlite3StrICmp(pIdx->azColl[i], pPk->azColl[iCol])==0
|
||||
){
|
||||
return 1;
|
||||
|
@ -2138,7 +2138,7 @@ static void recomputeColumnsNotIndexed(Index *pIdx){
|
|||
** Changes include:
|
||||
**
|
||||
** (1) Set all columns of the PRIMARY KEY schema object to be NOT NULL.
|
||||
** (2) Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY
|
||||
** (2) Convert P3 parameter of the OP_CreateBtree from BTREE_INTKEY
|
||||
** into BTREE_BLOBKEY.
|
||||
** (3) Bypass the creation of the sqlite_schema table entry
|
||||
** for the PRIMARY KEY as the primary key index is now
|
||||
|
@ -2184,13 +2184,13 @@ static void convertToWithoutRowidTable(Parse *pParse, Table *pTab){
|
|||
}
|
||||
|
||||
/* Locate the PRIMARY KEY index. Or, if this table was originally
|
||||
** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
|
||||
** an INTEGER PRIMARY KEY table, create a new PRIMARY KEY index.
|
||||
*/
|
||||
if( pTab->iPKey>=0 ){
|
||||
ExprList *pList;
|
||||
Token ipkToken;
|
||||
sqlite3TokenInit(&ipkToken, pTab->aCol[pTab->iPKey].zName);
|
||||
pList = sqlite3ExprListAppend(pParse, 0,
|
||||
pList = sqlite3ExprListAppend(pParse, 0,
|
||||
sqlite3ExprAlloc(db, TK_ID, &ipkToken, 0));
|
||||
if( pList==0 ) return;
|
||||
if( IN_RENAME_OBJECT ){
|
||||
|
@ -2386,7 +2386,7 @@ static void markExprListImmutable(ExprList *pList){
|
|||
** the sqlite_schema table. We do not want to create it again.
|
||||
**
|
||||
** If the pSelect argument is not NULL, it means that this routine
|
||||
** was called to create a table generated from a
|
||||
** was called to create a table generated from a
|
||||
** "CREATE TABLE ... AS SELECT ..." statement. The column names of
|
||||
** the new table will match the result set of the SELECT.
|
||||
*/
|
||||
|
@ -2523,7 +2523,7 @@ void sqlite3EndTable(
|
|||
|
||||
sqlite3VdbeAddOp1(v, OP_Close, 0);
|
||||
|
||||
/*
|
||||
/*
|
||||
** Initialize zType for the new view or table.
|
||||
*/
|
||||
if( p->pSelect==0 ){
|
||||
|
@ -2602,12 +2602,12 @@ void sqlite3EndTable(
|
|||
Token *pEnd2 = tabOpts ? &pParse->sLastToken : pEnd;
|
||||
n = (int)(pEnd2->z - pParse->sNameToken.z);
|
||||
if( pEnd2->z[0]!=';' ) n += pEnd2->n;
|
||||
zStmt = sqlite3MPrintf(db,
|
||||
zStmt = sqlite3MPrintf(db,
|
||||
"CREATE %s %.*s", zType2, n, pParse->sNameToken.z
|
||||
);
|
||||
}
|
||||
|
||||
/* A slot for the record has already been allocated in the
|
||||
/* A slot for the record has already been allocated in the
|
||||
** schema table. We just need to update that slot with all
|
||||
** the information we've collected.
|
||||
*/
|
||||
|
@ -2800,7 +2800,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
|
|||
** Actually, the error above is now caught prior to reaching this point.
|
||||
** But the following test is still important as it does come up
|
||||
** in the following:
|
||||
**
|
||||
**
|
||||
** CREATE TABLE main.ex1(a);
|
||||
** CREATE TEMP VIEW ex1 AS SELECT a FROM ex1;
|
||||
** SELECT * FROM temp.ex1;
|
||||
|
@ -2846,9 +2846,9 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
|
|||
** normally holds CHECK constraints on an ordinary table, but for
|
||||
** a VIEW it holds the list of column names.
|
||||
*/
|
||||
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
|
||||
sqlite3ColumnsFromExprList(pParse, pTable->pCheck,
|
||||
&pTable->nCol, &pTable->aCol);
|
||||
if( db->mallocFailed==0
|
||||
if( db->mallocFailed==0
|
||||
&& pParse->nErr==0
|
||||
&& pTable->nCol==pSel->pEList->nExpr
|
||||
){
|
||||
|
@ -2882,7 +2882,7 @@ int sqlite3ViewGetColumnNames(Parse *pParse, Table *pTable){
|
|||
pTable->nCol = 0;
|
||||
}
|
||||
#endif /* SQLITE_OMIT_VIEW */
|
||||
return nErr;
|
||||
return nErr;
|
||||
}
|
||||
#endif /* !defined(SQLITE_OMIT_VIEW) || !defined(SQLITE_OMIT_VIRTUALTABLE) */
|
||||
|
||||
|
@ -2918,7 +2918,7 @@ static void sqliteViewResetAll(sqlite3 *db, int idx){
|
|||
** on tables and/or indices that are the process of being deleted.
|
||||
** If you are unlucky, one of those deleted indices or tables might
|
||||
** have the same rootpage number as the real table or index that is
|
||||
** being moved. So we cannot stop searching after the first match
|
||||
** being moved. So we cannot stop searching after the first match
|
||||
** because the first match might be for one of the deleted indices
|
||||
** or tables and not the table/index that is actually being moved.
|
||||
** We must continue looping until all tables and indices with
|
||||
|
@ -2955,7 +2955,7 @@ void sqlite3RootPageMoved(sqlite3 *db, int iDb, Pgno iFrom, Pgno iTo){
|
|||
** Also write code to modify the sqlite_schema table and internal schema
|
||||
** if a root-page of another table is moved by the btree-layer whilst
|
||||
** erasing iTable (this can happen with an auto-vacuum database).
|
||||
*/
|
||||
*/
|
||||
static void destroyRootPage(Parse *pParse, int iTable, int iDb){
|
||||
Vdbe *v = sqlite3GetVdbe(pParse);
|
||||
int r1 = sqlite3GetTempReg(pParse);
|
||||
|
@ -2972,7 +2972,7 @@ static void destroyRootPage(Parse *pParse, int iTable, int iDb){
|
|||
** is in register NNN. See grammar rules associated with the TK_REGISTER
|
||||
** token for additional information.
|
||||
*/
|
||||
sqlite3NestedParse(pParse,
|
||||
sqlite3NestedParse(pParse,
|
||||
"UPDATE %Q." DFLT_SCHEMA_TABLE
|
||||
" SET rootpage=%d WHERE #%d AND rootpage=#%d",
|
||||
pParse->db->aDb[iDb].zDbSName, iTable, r1, r1);
|
||||
|
@ -2989,7 +2989,7 @@ static void destroyRootPage(Parse *pParse, int iTable, int iDb){
|
|||
static void destroyTable(Parse *pParse, Table *pTab){
|
||||
/* If the database may be auto-vacuum capable (if SQLITE_OMIT_AUTOVACUUM
|
||||
** is not defined), then it is important to call OP_Destroy on the
|
||||
** table and index root-pages in order, starting with the numerically
|
||||
** table and index root-pages in order, starting with the numerically
|
||||
** largest root-page number. This guarantees that none of the root-pages
|
||||
** to be destroyed is relocated by an earlier OP_Destroy. i.e. if the
|
||||
** following were coded:
|
||||
|
@ -2999,7 +2999,7 @@ static void destroyTable(Parse *pParse, Table *pTab){
|
|||
** OP_Destroy 5 0
|
||||
**
|
||||
** and root page 5 happened to be the largest root-page number in the
|
||||
** database, then root page 5 would be moved to page 4 by the
|
||||
** database, then root page 5 would be moved to page 4 by the
|
||||
** "OP_Destroy 4 0" opcode. The subsequent "OP_Destroy 5 0" would hit
|
||||
** a free-list page.
|
||||
*/
|
||||
|
@ -3080,7 +3080,7 @@ void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
|
|||
*/
|
||||
pTrigger = sqlite3TriggerList(pParse, pTab);
|
||||
while( pTrigger ){
|
||||
assert( pTrigger->pSchema==pTab->pSchema ||
|
||||
assert( pTrigger->pSchema==pTab->pSchema ||
|
||||
pTrigger->pSchema==db->aDb[1].pSchema );
|
||||
sqlite3DropTriggerPtr(pParse, pTrigger);
|
||||
pTrigger = pTrigger->pNext;
|
||||
|
@ -3107,7 +3107,7 @@ void sqlite3CodeDropTable(Parse *pParse, Table *pTab, int iDb, int isView){
|
|||
** created in the temp database that refers to a table in another
|
||||
** database.
|
||||
*/
|
||||
sqlite3NestedParse(pParse,
|
||||
sqlite3NestedParse(pParse,
|
||||
"DELETE FROM %Q." DFLT_SCHEMA_TABLE
|
||||
" WHERE tbl_name=%Q and type!='trigger'",
|
||||
pDb->zDbSName, pTab->zName);
|
||||
|
@ -3350,8 +3350,8 @@ void sqlite3CreateForeignKey(
|
|||
}
|
||||
}
|
||||
if( j>=p->nCol ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"unknown column \"%s\" in foreign key definition",
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"unknown column \"%s\" in foreign key definition",
|
||||
pFromCol->a[i].zEName);
|
||||
goto fk_end;
|
||||
}
|
||||
|
@ -3377,7 +3377,7 @@ void sqlite3CreateForeignKey(
|
|||
pFKey->aAction[1] = (u8)((flags >> 8 ) & 0xff); /* ON UPDATE action */
|
||||
|
||||
assert( sqlite3SchemaMutexHeld(db, 0, p->pSchema) );
|
||||
pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash,
|
||||
pNextTo = (FKey *)sqlite3HashInsert(&p->pSchema->fkeyHash,
|
||||
pFKey->zTo, (void *)pFKey
|
||||
);
|
||||
if( pNextTo==pFKey ){
|
||||
|
@ -3483,7 +3483,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
|
|||
sqlite3VdbeAddOp2(v, OP_Next, iTab, addr1+1); VdbeCoverage(v);
|
||||
sqlite3VdbeJumpHere(v, addr1);
|
||||
if( memRootPage<0 ) sqlite3VdbeAddOp2(v, OP_Clear, tnum, iDb);
|
||||
sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, (int)tnum, iDb,
|
||||
sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, (int)tnum, iDb,
|
||||
(char *)pKey, P4_KEYINFO);
|
||||
sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0));
|
||||
|
||||
|
@ -3502,7 +3502,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){
|
|||
** user function that throws an exception when it is evaluated. But the
|
||||
** overhead of adding a statement journal to a CREATE INDEX statement is
|
||||
** very small (since most of the pages written do not contain content that
|
||||
** needs to be restored if the statement aborts), so we call
|
||||
** needs to be restored if the statement aborts), so we call
|
||||
** sqlite3MayAbort() for all CREATE INDEX statements. */
|
||||
sqlite3MayAbort(pParse);
|
||||
addr2 = sqlite3VdbeCurrentAddr(v);
|
||||
|
@ -3575,7 +3575,7 @@ int sqlite3HasExplicitNulls(Parse *pParse, ExprList *pList){
|
|||
for(i=0; i<pList->nExpr; i++){
|
||||
if( pList->a[i].bNulls ){
|
||||
u8 sf = pList->a[i].sortFlags;
|
||||
sqlite3ErrorMsg(pParse, "unsupported use of NULLS %s",
|
||||
sqlite3ErrorMsg(pParse, "unsupported use of NULLS %s",
|
||||
(sf==0 || sf==3) ? "FIRST" : "LAST"
|
||||
);
|
||||
return 1;
|
||||
|
@ -3586,8 +3586,8 @@ int sqlite3HasExplicitNulls(Parse *pParse, ExprList *pList){
|
|||
}
|
||||
|
||||
/*
|
||||
** Create a new index for an SQL table. pName1.pName2 is the name of the index
|
||||
** and pTblList is the name of the table that is to be indexed. Both will
|
||||
** Create a new index for an SQL table. pName1.pName2 is the name of the index
|
||||
** and pTblList is the name of the table that is to be indexed. Both will
|
||||
** be NULL for a primary key or an index that is created to satisfy a
|
||||
** UNIQUE constraint. If pTable and pIndex are NULL, use pParse->pNewTable
|
||||
** as the table to be indexed. pParse->pNewTable is a table that is
|
||||
|
@ -3595,7 +3595,7 @@ int sqlite3HasExplicitNulls(Parse *pParse, ExprList *pList){
|
|||
**
|
||||
** pList is a list of columns to be indexed. pList will be NULL if this
|
||||
** is a primary key or unique-constraint on the most recent column added
|
||||
** to the table currently under construction.
|
||||
** to the table currently under construction.
|
||||
*/
|
||||
void sqlite3CreateIndex(
|
||||
Parse *pParse, /* All information about this parse */
|
||||
|
@ -3645,7 +3645,7 @@ void sqlite3CreateIndex(
|
|||
*/
|
||||
if( pTblName!=0 ){
|
||||
|
||||
/* Use the two-part index name to determine the database
|
||||
/* Use the two-part index name to determine the database
|
||||
** to search for the table. 'Fix' the table name to this db
|
||||
** before looking up the table.
|
||||
*/
|
||||
|
@ -3677,7 +3677,7 @@ void sqlite3CreateIndex(
|
|||
assert( db->mallocFailed==0 || pTab==0 );
|
||||
if( pTab==0 ) goto exit_create_index;
|
||||
if( iDb==1 && db->aDb[iDb].pSchema!=pTab->pSchema ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"cannot create a TEMP index on non-TEMP table \"%s\"",
|
||||
pTab->zName);
|
||||
goto exit_create_index;
|
||||
|
@ -3694,7 +3694,7 @@ void sqlite3CreateIndex(
|
|||
|
||||
assert( pTab!=0 );
|
||||
assert( pParse->nErr==0 );
|
||||
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
|
||||
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0
|
||||
&& db->init.busy==0
|
||||
&& pTblName!=0
|
||||
#if SQLITE_USER_AUTHENTICATION
|
||||
|
@ -3719,7 +3719,7 @@ void sqlite3CreateIndex(
|
|||
|
||||
/*
|
||||
** Find the name of the index. Make sure there is not already another
|
||||
** index or table with the same name.
|
||||
** index or table with the same name.
|
||||
**
|
||||
** Exception: If we are reading the names of permanent indices from the
|
||||
** sqlite_schema table (because some other process changed the schema) and
|
||||
|
@ -3817,8 +3817,8 @@ void sqlite3CreateIndex(
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Allocate the index structure.
|
||||
/*
|
||||
** Allocate the index structure.
|
||||
*/
|
||||
nName = sqlite3Strlen30(zName);
|
||||
nExtraCol = pPk ? pPk->nKeyCol : 1;
|
||||
|
@ -3936,7 +3936,7 @@ void sqlite3CreateIndex(
|
|||
int x = pPk->aiColumn[j];
|
||||
assert( x>=0 );
|
||||
if( isDupColumn(pIndex, pIndex->nKeyCol, pPk, j) ){
|
||||
pIndex->nColumn--;
|
||||
pIndex->nColumn--;
|
||||
}else{
|
||||
testcase( hasColumn(pIndex->aiColumn,pIndex->nKeyCol,x) );
|
||||
pIndex->aiColumn[i] = x;
|
||||
|
@ -3955,7 +3955,7 @@ void sqlite3CreateIndex(
|
|||
|
||||
/* If this index contains every column of its table, then mark
|
||||
** it as a covering index */
|
||||
assert( HasRowid(pTab)
|
||||
assert( HasRowid(pTab)
|
||||
|| pTab->iPKey<0 || sqlite3TableColumnToIndex(pIndex, pTab->iPKey)>=0 );
|
||||
recomputeColumnsNotIndexed(pIndex);
|
||||
if( pTblName!=0 && pIndex->nColumn>=pTab->nCol ){
|
||||
|
@ -4011,13 +4011,13 @@ void sqlite3CreateIndex(
|
|||
if( pIdx->onError!=pIndex->onError ){
|
||||
/* This constraint creates the same index as a previous
|
||||
** constraint specified somewhere in the CREATE TABLE statement.
|
||||
** However the ON CONFLICT clauses are different. If both this
|
||||
** However the ON CONFLICT clauses are different. If both this
|
||||
** constraint and the previous equivalent constraint have explicit
|
||||
** ON CONFLICT clauses this is an error. Otherwise, use the
|
||||
** explicitly specified behavior for the index.
|
||||
*/
|
||||
if( !(pIdx->onError==OE_Default || pIndex->onError==OE_Default) ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"conflicting ON CONFLICT clauses specified", 0);
|
||||
}
|
||||
if( pIdx->onError==OE_Default ){
|
||||
|
@ -4038,7 +4038,7 @@ void sqlite3CreateIndex(
|
|||
if( !IN_RENAME_OBJECT ){
|
||||
|
||||
/* Link the new Index structure to its table and to the other
|
||||
** in-memory database structures.
|
||||
** in-memory database structures.
|
||||
*/
|
||||
assert( pParse->nErr==0 );
|
||||
if( db->init.busy ){
|
||||
|
@ -4053,7 +4053,7 @@ void sqlite3CreateIndex(
|
|||
goto exit_create_index;
|
||||
}
|
||||
}
|
||||
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
|
||||
p = sqlite3HashInsert(&pIndex->pSchema->idxHash,
|
||||
pIndex->zName, pIndex);
|
||||
if( p ){
|
||||
assert( p==pIndex ); /* Malloc must have failed */
|
||||
|
@ -4087,9 +4087,9 @@ void sqlite3CreateIndex(
|
|||
sqlite3BeginWriteOperation(pParse, 1, iDb);
|
||||
|
||||
/* Create the rootpage for the index using CreateIndex. But before
|
||||
** doing so, code a Noop instruction and store its address in
|
||||
** Index.tnum. This is required in case this index is actually a
|
||||
** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
|
||||
** doing so, code a Noop instruction and store its address in
|
||||
** Index.tnum. This is required in case this index is actually a
|
||||
** PRIMARY KEY and the table is actually a WITHOUT ROWID table. In
|
||||
** that case the convertToWithoutRowidTable() routine will replace
|
||||
** the Noop with a Goto to jump over the VDBE code generated below. */
|
||||
pIndex->tnum = (Pgno)sqlite3VdbeAddOp0(v, OP_Noop);
|
||||
|
@ -4113,7 +4113,7 @@ void sqlite3CreateIndex(
|
|||
|
||||
/* Add an entry in sqlite_schema for this index
|
||||
*/
|
||||
sqlite3NestedParse(pParse,
|
||||
sqlite3NestedParse(pParse,
|
||||
"INSERT INTO %Q." DFLT_SCHEMA_TABLE " VALUES('index',%Q,%Q,#%d,%Q);",
|
||||
db->aDb[iDb].zDbSName,
|
||||
pIndex->zName,
|
||||
|
@ -4215,7 +4215,7 @@ void sqlite3DefaultRowEst(Index *pIdx){
|
|||
/* Indexes with default row estimates should not have stat1 data */
|
||||
assert( !pIdx->hasStat1 );
|
||||
|
||||
/* Set the first entry (number of rows in the index) to the estimated
|
||||
/* Set the first entry (number of rows in the index) to the estimated
|
||||
** number of rows in the table, or half the number of rows in the table
|
||||
** for a partial index.
|
||||
**
|
||||
|
@ -4510,7 +4510,7 @@ SrcList *sqlite3SrcListEnlarge(
|
|||
** database name prefix. Like this: "database.table". The pDatabase
|
||||
** points to the table name and the pTable points to the database name.
|
||||
** The SrcList.a[].zName field is filled with the table name which might
|
||||
** come from pTable (if pDatabase is NULL) or from pDatabase.
|
||||
** come from pTable (if pDatabase is NULL) or from pDatabase.
|
||||
** SrcList.a[].zDatabase is filled with the database name from pTable,
|
||||
** or with NULL if no database is specified.
|
||||
**
|
||||
|
@ -4641,7 +4641,7 @@ SrcList *sqlite3SrcListAppendFromTerm(
|
|||
SrcItem *pItem;
|
||||
sqlite3 *db = pParse->db;
|
||||
if( !p && (pOn || pUsing) ){
|
||||
sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s",
|
||||
sqlite3ErrorMsg(pParse, "a JOIN clause is required before %s",
|
||||
(pOn ? "ON" : "USING")
|
||||
);
|
||||
goto append_from_error;
|
||||
|
@ -4676,7 +4676,7 @@ SrcList *sqlite3SrcListAppendFromTerm(
|
|||
}
|
||||
|
||||
/*
|
||||
** Add an INDEXED BY or NOT INDEXED clause to the most recently added
|
||||
** Add an INDEXED BY or NOT INDEXED clause to the most recently added
|
||||
** element of the source-list passed as the second argument.
|
||||
*/
|
||||
void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){
|
||||
|
@ -4689,7 +4689,7 @@ void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){
|
|||
assert( pItem->fg.isIndexedBy==0 );
|
||||
assert( pItem->fg.isTabFunc==0 );
|
||||
if( pIndexedBy->n==1 && !pIndexedBy->z ){
|
||||
/* A "NOT INDEXED" clause was supplied. See parse.y
|
||||
/* A "NOT INDEXED" clause was supplied. See parse.y
|
||||
** construct "indexed_opt" for details. */
|
||||
pItem->fg.notIndexed = 1;
|
||||
}else{
|
||||
|
@ -4703,7 +4703,7 @@ void sqlite3SrcListIndexedBy(Parse *pParse, SrcList *p, Token *pIndexedBy){
|
|||
** Append the contents of SrcList p2 to SrcList p1 and return the resulting
|
||||
** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2
|
||||
** are deleted by this function.
|
||||
*/
|
||||
*/
|
||||
SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){
|
||||
assert( p1 && p1->nSrc==1 );
|
||||
if( p2 ){
|
||||
|
@ -4808,7 +4808,7 @@ void sqlite3EndTransaction(Parse *pParse, int eType){
|
|||
assert( pParse->db!=0 );
|
||||
assert( eType==TK_COMMIT || eType==TK_END || eType==TK_ROLLBACK );
|
||||
isRollback = eType==TK_ROLLBACK;
|
||||
if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION,
|
||||
if( sqlite3AuthCheck(pParse, SQLITE_TRANSACTION,
|
||||
isRollback ? "ROLLBACK" : "COMMIT", 0, 0) ){
|
||||
return;
|
||||
}
|
||||
|
@ -4820,7 +4820,7 @@ void sqlite3EndTransaction(Parse *pParse, int eType){
|
|||
|
||||
/*
|
||||
** This function is called by the parser when it parses a command to create,
|
||||
** release or rollback an SQL savepoint.
|
||||
** release or rollback an SQL savepoint.
|
||||
*/
|
||||
void sqlite3Savepoint(Parse *pParse, int op, Token *pName){
|
||||
char *zName = sqlite3NameFromToken(pParse->db, pName);
|
||||
|
@ -4847,7 +4847,7 @@ int sqlite3OpenTempDatabase(Parse *pParse){
|
|||
if( db->aDb[1].pBt==0 && !pParse->explain ){
|
||||
int rc;
|
||||
Btree *pBt;
|
||||
static const int flags =
|
||||
static const int flags =
|
||||
SQLITE_OPEN_READWRITE |
|
||||
SQLITE_OPEN_CREATE |
|
||||
SQLITE_OPEN_EXCLUSIVE |
|
||||
|
@ -4895,7 +4895,7 @@ void sqlite3CodeVerifySchema(Parse *pParse, int iDb){
|
|||
|
||||
|
||||
/*
|
||||
** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each
|
||||
** If argument zDb is NULL, then call sqlite3CodeVerifySchema() for each
|
||||
** attached database. Otherwise, invoke it for the database named zDb only.
|
||||
*/
|
||||
void sqlite3CodeVerifyNamedSchema(Parse *pParse, const char *zDb){
|
||||
|
@ -4941,9 +4941,9 @@ void sqlite3MultiWrite(Parse *pParse){
|
|||
pToplevel->isMultiWrite = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** The code generator calls this routine if is discovers that it is
|
||||
** possible to abort a statement prior to completion. In order to
|
||||
** possible to abort a statement prior to completion. In order to
|
||||
** perform this abort without corrupting the database, we need to make
|
||||
** sure that the statement is protected by a statement transaction.
|
||||
**
|
||||
|
@ -4952,7 +4952,7 @@ void sqlite3MultiWrite(Parse *pParse){
|
|||
** such that the abort must occur after the multiwrite. This makes
|
||||
** some statements involving the REPLACE conflict resolution algorithm
|
||||
** go a little faster. But taking advantage of this time dependency
|
||||
** makes it more difficult to prove that the code is correct (in
|
||||
** makes it more difficult to prove that the code is correct (in
|
||||
** particular, it prevents us from writing an effective
|
||||
** implementation of sqlite3AssertMayAbort()) and so we have chosen
|
||||
** to take the safe route and skip the optimization.
|
||||
|
@ -4999,7 +4999,7 @@ void sqlite3UniqueConstraint(
|
|||
StrAccum errMsg;
|
||||
Table *pTab = pIdx->pTable;
|
||||
|
||||
sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0,
|
||||
sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0,
|
||||
pParse->db->aLimit[SQLITE_LIMIT_LENGTH]);
|
||||
if( pIdx->aColExpr ){
|
||||
sqlite3_str_appendf(&errMsg, "index '%q'", pIdx->zName);
|
||||
|
@ -5015,8 +5015,8 @@ void sqlite3UniqueConstraint(
|
|||
}
|
||||
}
|
||||
zErr = sqlite3StrAccumFinish(&errMsg);
|
||||
sqlite3HaltConstraint(pParse,
|
||||
IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
|
||||
sqlite3HaltConstraint(pParse,
|
||||
IsPrimaryKeyIndex(pIdx) ? SQLITE_CONSTRAINT_PRIMARYKEY
|
||||
: SQLITE_CONSTRAINT_UNIQUE,
|
||||
onError, zErr, P4_DYNAMIC, P5_ConstraintUnique);
|
||||
}
|
||||
|
@ -5028,7 +5028,7 @@ void sqlite3UniqueConstraint(
|
|||
void sqlite3RowidConstraint(
|
||||
Parse *pParse, /* Parsing context */
|
||||
int onError, /* Conflict resolution algorithm */
|
||||
Table *pTab /* The table with the non-unique rowid */
|
||||
Table *pTab /* The table with the non-unique rowid */
|
||||
){
|
||||
char *zMsg;
|
||||
int rc;
|
||||
|
@ -5270,8 +5270,8 @@ void sqlite3CteDelete(sqlite3 *db, Cte *pCte){
|
|||
sqlite3DbFree(db, pCte);
|
||||
}
|
||||
|
||||
/*
|
||||
** This routine is invoked once per CTE by the parser while parsing a
|
||||
/*
|
||||
** This routine is invoked once per CTE by the parser while parsing a
|
||||
** WITH clause. The CTE described by teh third argument is added to
|
||||
** the WITH clause of the second argument. If the second argument is
|
||||
** NULL, then a new WITH argument is created.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue