mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 13:52:28 +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
102
third_party/sqlite3/insert.c
vendored
102
third_party/sqlite3/insert.c
vendored
|
@ -16,7 +16,7 @@
|
|||
/* clang-format off */
|
||||
|
||||
/*
|
||||
** Generate code that will
|
||||
** Generate code that will
|
||||
**
|
||||
** (1) acquire a lock for table pTab then
|
||||
** (2) open pTab as cursor iCur.
|
||||
|
@ -36,7 +36,7 @@ void sqlite3OpenTable(
|
|||
assert( pParse->pVdbe!=0 );
|
||||
v = pParse->pVdbe;
|
||||
assert( opcode==OP_OpenWrite || opcode==OP_OpenRead );
|
||||
sqlite3TableLock(pParse, iDb, pTab->tnum,
|
||||
sqlite3TableLock(pParse, iDb, pTab->tnum,
|
||||
(opcode==OP_OpenWrite)?1:0, pTab->zName);
|
||||
if( HasRowid(pTab) ){
|
||||
sqlite3VdbeAddOp4Int(v, opcode, iCur, pTab->tnum, iDb, pTab->nNVCol);
|
||||
|
@ -53,7 +53,7 @@ void sqlite3OpenTable(
|
|||
|
||||
/*
|
||||
** Return a pointer to the column affinity string associated with index
|
||||
** pIdx. A column affinity string has one character for each column in
|
||||
** pIdx. A column affinity string has one character for each column in
|
||||
** the table, according to the affinity of the column:
|
||||
**
|
||||
** Character Column affinity
|
||||
|
@ -106,7 +106,7 @@ const char *sqlite3IndexAffinityStr(sqlite3 *db, Index *pIdx){
|
|||
}
|
||||
pIdx->zColAff[n] = 0;
|
||||
}
|
||||
|
||||
|
||||
return pIdx->zColAff;
|
||||
}
|
||||
|
||||
|
@ -165,9 +165,9 @@ void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
|
|||
|
||||
/*
|
||||
** Return non-zero if the table pTab in database iDb or any of its indices
|
||||
** have been opened at any point in the VDBE program. This is used to see if
|
||||
** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
|
||||
** run without using a temporary table for the results of the SELECT.
|
||||
** have been opened at any point in the VDBE program. This is used to see if
|
||||
** a statement of the form "INSERT INTO <iDb, pTab> SELECT ..." can
|
||||
** run without using a temporary table for the results of the SELECT.
|
||||
*/
|
||||
static int readsTable(Parse *p, int iDb, Table *pTab){
|
||||
Vdbe *v = sqlite3GetVdbe(p);
|
||||
|
@ -389,7 +389,7 @@ static int autoIncBegin(
|
|||
|
||||
/*
|
||||
** This routine generates code that will initialize all of the
|
||||
** register used by the autoincrement tracker.
|
||||
** register used by the autoincrement tracker.
|
||||
*/
|
||||
void sqlite3AutoincrementBegin(Parse *pParse){
|
||||
AutoincInfo *p; /* Information about an AUTOINCREMENT */
|
||||
|
@ -418,7 +418,7 @@ void sqlite3AutoincrementBegin(Parse *pParse){
|
|||
/* 8 */ {OP_Goto, 0, 11, 0},
|
||||
/* 9 */ {OP_Next, 0, 2, 0},
|
||||
/* 10 */ {OP_Integer, 0, 0, 0},
|
||||
/* 11 */ {OP_Close, 0, 0, 0}
|
||||
/* 11 */ {OP_Close, 0, 0, 0}
|
||||
};
|
||||
VdbeOp *aOp;
|
||||
pDb = &db->aDb[p->iDb];
|
||||
|
@ -770,7 +770,7 @@ void sqlite3Insert(
|
|||
regData = regRowid+1;
|
||||
|
||||
/* If the INSERT statement included an IDLIST term, then make sure
|
||||
** all elements of the IDLIST really are columns of the table and
|
||||
** all elements of the IDLIST really are columns of the table and
|
||||
** remember the column indices.
|
||||
**
|
||||
** If the table has an INTEGER PRIMARY KEY column and that column
|
||||
|
@ -803,7 +803,7 @@ void sqlite3Insert(
|
|||
}
|
||||
#ifndef SQLITE_OMIT_GENERATED_COLUMNS
|
||||
if( pTab->aCol[j].colFlags & (COLFLAG_STORED|COLFLAG_VIRTUAL) ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"cannot INSERT into generated column \"%s\"",
|
||||
pTab->aCol[j].zName);
|
||||
goto insert_cleanup;
|
||||
|
@ -858,7 +858,7 @@ void sqlite3Insert(
|
|||
** the destination table (template 3).
|
||||
**
|
||||
** A temp table must be used if the table being updated is also one
|
||||
** of the tables being read by the SELECT statement. Also use a
|
||||
** of the tables being read by the SELECT statement. Also use a
|
||||
** temp table in the case of row triggers.
|
||||
*/
|
||||
if( pTrigger || readsTable(pParse, iDb, pTab) ){
|
||||
|
@ -894,7 +894,7 @@ void sqlite3Insert(
|
|||
sqlite3ReleaseTempReg(pParse, regTempRowid);
|
||||
}
|
||||
}else{
|
||||
/* This is the case if the data for the INSERT is coming from a
|
||||
/* This is the case if the data for the INSERT is coming from a
|
||||
** single-row VALUES clause
|
||||
*/
|
||||
NameContext sNC;
|
||||
|
@ -913,7 +913,7 @@ void sqlite3Insert(
|
|||
}
|
||||
|
||||
/* If there is no IDLIST term but the table has an integer primary
|
||||
** key, the set the ipkColumn variable to the integer primary key
|
||||
** key, the set the ipkColumn variable to the integer primary key
|
||||
** column index in the original table definition.
|
||||
*/
|
||||
if( pColumn==0 && nColumn>0 ){
|
||||
|
@ -944,7 +944,7 @@ void sqlite3Insert(
|
|||
}
|
||||
}
|
||||
if( nColumn!=(pTab->nCol-nHidden) ){
|
||||
sqlite3ErrorMsg(pParse,
|
||||
sqlite3ErrorMsg(pParse,
|
||||
"table %S has %d columns but %d values were supplied",
|
||||
pTabList, 0, pTab->nCol-nHidden, nColumn);
|
||||
goto insert_cleanup;
|
||||
|
@ -954,7 +954,7 @@ void sqlite3Insert(
|
|||
sqlite3ErrorMsg(pParse, "%d values for %d columns", nColumn, pColumn->nId);
|
||||
goto insert_cleanup;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize the count of rows to be inserted
|
||||
*/
|
||||
if( (db->flags & SQLITE_CountRows)!=0
|
||||
|
@ -1111,7 +1111,7 @@ void sqlite3Insert(
|
|||
}
|
||||
|
||||
if( useTempTable ){
|
||||
sqlite3VdbeAddOp3(v, OP_Column, srcTab, k, iRegStore);
|
||||
sqlite3VdbeAddOp3(v, OP_Column, srcTab, k, iRegStore);
|
||||
}else if( pSelect ){
|
||||
if( regFromSelect!=regData ){
|
||||
sqlite3VdbeAddOp2(v, OP_SCopy, regFromSelect+k, iRegStore);
|
||||
|
@ -1177,7 +1177,7 @@ void sqlite3Insert(
|
|||
}
|
||||
|
||||
/* Fire BEFORE or INSTEAD OF triggers */
|
||||
sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE,
|
||||
sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_BEFORE,
|
||||
pTab, regCols-pTab->nCol-1, onError, endOfLoop);
|
||||
|
||||
sqlite3ReleaseTempRange(pParse, regCols, pTab->nCol+1);
|
||||
|
@ -1260,7 +1260,7 @@ void sqlite3Insert(
|
|||
** constraints or (b) there are no triggers and this table is not a
|
||||
** parent table in a foreign key constraint. It is safe to set the
|
||||
** flag in the second case as if any REPLACE constraint is hit, an
|
||||
** OP_Delete or OP_IdxDelete instruction will be executed on each
|
||||
** OP_Delete or OP_IdxDelete instruction will be executed on each
|
||||
** cursor that is disturbed. And these instructions both clear the
|
||||
** VdbeCursor.seekResult variable, disabling the OPFLAG_USESEEKRESULT
|
||||
** functionality. */
|
||||
|
@ -1279,7 +1279,7 @@ void sqlite3Insert(
|
|||
|
||||
if( pTrigger ){
|
||||
/* Code AFTER triggers */
|
||||
sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER,
|
||||
sqlite3CodeRowTrigger(pParse, pTrigger, TK_INSERT, 0, TRIGGER_AFTER,
|
||||
pTab, regData-2-pTab->nCol, onError, endOfLoop);
|
||||
}
|
||||
|
||||
|
@ -1317,7 +1317,7 @@ insert_end:
|
|||
}
|
||||
|
||||
/*
|
||||
** Return the number of rows inserted. If this routine is
|
||||
** Return the number of rows inserted. If this routine is
|
||||
** generating code because of a call to sqlite3NestedParse(), do not
|
||||
** invoke the callback function.
|
||||
*/
|
||||
|
@ -1350,7 +1350,7 @@ insert_cleanup:
|
|||
#endif
|
||||
|
||||
/*
|
||||
** Meanings of bits in of pWalker->eCode for
|
||||
** Meanings of bits in of pWalker->eCode for
|
||||
** sqlite3ExprReferencesUpdatedColumn()
|
||||
*/
|
||||
#define CKCNSTRNT_COLUMN 0x01 /* CHECK constraint uses a changing column */
|
||||
|
@ -1431,7 +1431,7 @@ struct IndexIterator {
|
|||
union {
|
||||
struct { /* Use this object for eType==0: A Index.pNext list */
|
||||
Index *pIdx; /* The current Index */
|
||||
} lx;
|
||||
} lx;
|
||||
struct { /* Use this object for eType==1; Array of IndexListTerm */
|
||||
int nIdx; /* Size of the array */
|
||||
IndexListTerm *aIdx; /* Array of IndexListTerms */
|
||||
|
@ -1475,7 +1475,7 @@ static Index *indexIteratorNext(IndexIterator *pIter, int *pIx){
|
|||
return pIter->u.lx.pIdx;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Generate code to do constraint checks prior to an INSERT or an UPDATE
|
||||
** on table pTab.
|
||||
|
@ -1614,9 +1614,9 @@ void sqlite3GenerateConstraintChecks(
|
|||
assert( v!=0 );
|
||||
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
|
||||
nCol = pTab->nCol;
|
||||
|
||||
|
||||
/* pPk is the PRIMARY KEY index for WITHOUT ROWID tables and NULL for
|
||||
** normal rowid tables. nPkField is the number of key fields in the
|
||||
** normal rowid tables. nPkField is the number of key fields in the
|
||||
** pPk index or 1 for a rowid table. In other words, nPkField is the
|
||||
** number of fields in the true primary key of the table. */
|
||||
if( HasRowid(pTab) ){
|
||||
|
@ -1990,10 +1990,10 @@ void sqlite3GenerateConstraintChecks(
|
|||
** the triggers and remove both the table and index b-tree entries.
|
||||
**
|
||||
** Otherwise, if there are no triggers or the recursive-triggers
|
||||
** flag is not set, but the table has one or more indexes, call
|
||||
** GenerateRowIndexDelete(). This removes the index b-tree entries
|
||||
** only. The table b-tree entry will be replaced by the new entry
|
||||
** when it is inserted.
|
||||
** flag is not set, but the table has one or more indexes, call
|
||||
** GenerateRowIndexDelete(). This removes the index b-tree entries
|
||||
** only. The table b-tree entry will be replaced by the new entry
|
||||
** when it is inserted.
|
||||
**
|
||||
** If either GenerateRowDelete() or GenerateRowIndexDelete() is called,
|
||||
** also invoke MultiWrite() to indicate that this VDBE may require
|
||||
|
@ -2125,7 +2125,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
#endif
|
||||
sqlite3VdbeReleaseRegisters(pParse, regIdx, pIdx->nColumn, 0, 0);
|
||||
|
||||
/* In an UPDATE operation, if this index is the PRIMARY KEY index
|
||||
/* In an UPDATE operation, if this index is the PRIMARY KEY index
|
||||
** of a WITHOUT ROWID table and there has been no change the
|
||||
** primary key, then no collision is possible. The collision detection
|
||||
** logic below can all be skipped. */
|
||||
|
@ -2136,7 +2136,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
|
||||
/* Find out what action to take in case there is a uniqueness conflict */
|
||||
onError = pIdx->onError;
|
||||
if( onError==OE_None ){
|
||||
if( onError==OE_None ){
|
||||
sqlite3VdbeResolveLabel(v, addrUniqueOk);
|
||||
continue; /* pIdx is not a UNIQUE index */
|
||||
}
|
||||
|
@ -2164,7 +2164,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
**
|
||||
** This is not possible for ENABLE_PREUPDATE_HOOK builds, as the row
|
||||
** must be explicitly deleted in order to ensure any pre-update hook
|
||||
** is invoked. */
|
||||
** is invoked. */
|
||||
#ifndef SQLITE_ENABLE_PREUPDATE_HOOK
|
||||
if( (ix==0 && pIdx->pNext==0) /* Condition 3 */
|
||||
&& pPk==pIdx /* Condition 2 */
|
||||
|
@ -2181,7 +2181,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
|
||||
/* Check to see if the new index entry will be unique */
|
||||
sqlite3VdbeVerifyAbortable(v, onError);
|
||||
addrConflictCk =
|
||||
addrConflictCk =
|
||||
sqlite3VdbeAddOp4Int(v, OP_NoConflict, iThisCur, addrUniqueOk,
|
||||
regIdx, pIdx->nKeyCol); VdbeCoverage(v);
|
||||
|
||||
|
@ -2211,7 +2211,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
}
|
||||
}
|
||||
if( isUpdate ){
|
||||
/* If currently processing the PRIMARY KEY of a WITHOUT ROWID
|
||||
/* If currently processing the PRIMARY KEY of a WITHOUT ROWID
|
||||
** table, only conflict if the new PRIMARY KEY values are actually
|
||||
** different from the old.
|
||||
**
|
||||
|
@ -2221,7 +2221,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
int addrJump = sqlite3VdbeCurrentAddr(v)+pPk->nKeyCol;
|
||||
int op = OP_Ne;
|
||||
int regCmp = (IsPrimaryKeyIndex(pIdx) ? regIdx : regR);
|
||||
|
||||
|
||||
for(i=0; i<pPk->nKeyCol; i++){
|
||||
char *p4 = (char*)sqlite3LocateCollSeq(pParse, pPk->azColl[i]);
|
||||
x = pPk->aiColumn[i];
|
||||
|
@ -2231,7 +2231,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
op = OP_Eq;
|
||||
}
|
||||
x = sqlite3TableColumnToStorage(pTab, x);
|
||||
sqlite3VdbeAddOp4(v, op,
|
||||
sqlite3VdbeAddOp4(v, op,
|
||||
regOldData+1+x, addrJump, regCmp+i, p4, P4_COLLSEQ
|
||||
);
|
||||
sqlite3VdbeChangeP5(v, SQLITE_NOTNULL);
|
||||
|
@ -2340,7 +2340,7 @@ void sqlite3GenerateConstraintChecks(
|
|||
}
|
||||
sqlite3VdbeResolveLabel(v, addrUniqueOk);
|
||||
if( regR!=regIdx ) sqlite3ReleaseTempRange(pParse, regR, nPkField);
|
||||
if( pUpsertClause
|
||||
if( pUpsertClause
|
||||
&& upsertIpkReturn
|
||||
&& sqlite3UpsertNextIsIPK(pUpsertClause)
|
||||
){
|
||||
|
@ -2656,7 +2656,7 @@ static int xferCompatibleIndex(Index *pDest, Index *pSrc){
|
|||
**
|
||||
** INSERT INTO tab1 SELECT * FROM tab2;
|
||||
**
|
||||
** The xfer optimization transfers raw records from tab2 over to tab1.
|
||||
** The xfer optimization transfers raw records from tab2 over to tab1.
|
||||
** Columns are not decoded and reassembled, which greatly improves
|
||||
** performance. Raw index records are transferred in the same way.
|
||||
**
|
||||
|
@ -2791,8 +2791,8 @@ static int xferOptimization(
|
|||
Column *pDestCol = &pDest->aCol[i];
|
||||
Column *pSrcCol = &pSrc->aCol[i];
|
||||
#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
|
||||
if( (db->mDbFlags & DBFLAG_Vacuum)==0
|
||||
&& (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN
|
||||
if( (db->mDbFlags & DBFLAG_Vacuum)==0
|
||||
&& (pDestCol->colFlags | pSrcCol->colFlags) & COLFLAG_HIDDEN
|
||||
){
|
||||
return 0; /* Neither table may have __hidden__ columns */
|
||||
}
|
||||
|
@ -2809,7 +2809,7 @@ static int xferOptimization(
|
|||
**
|
||||
** Nevertheless, this is a useful notational shorthand to tell SQLite
|
||||
** to do a bulk transfer all of the content from t1 over to t2.
|
||||
**
|
||||
**
|
||||
** We could, in theory, disable this (except for internal use by the
|
||||
** VACUUM command where it is actually needed). But why do that? It
|
||||
** seems harmless enough, and provides a useful service.
|
||||
|
@ -2843,7 +2843,7 @@ static int xferOptimization(
|
|||
if( (pDestCol->colFlags & COLFLAG_GENERATED)==0 && i>0 ){
|
||||
assert( pDestCol->pDflt==0 || pDestCol->pDflt->op==TK_SPAN );
|
||||
assert( pSrcCol->pDflt==0 || pSrcCol->pDflt->op==TK_SPAN );
|
||||
if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
|
||||
if( (pDestCol->pDflt==0)!=(pSrcCol->pDflt==0)
|
||||
|| (pDestCol->pDflt && strcmp(pDestCol->pDflt->u.zToken,
|
||||
pSrcCol->pDflt->u.zToken)!=0)
|
||||
){
|
||||
|
@ -2877,7 +2877,7 @@ static int xferOptimization(
|
|||
#ifndef SQLITE_OMIT_FOREIGN_KEY
|
||||
/* Disallow the transfer optimization if the destination table constains
|
||||
** any foreign key constraints. This is more restrictive than necessary.
|
||||
** But the main beneficiary of the transfer optimization is the VACUUM
|
||||
** But the main beneficiary of the transfer optimization is the VACUUM
|
||||
** command, and the VACUUM command disables foreign key constraints. So
|
||||
** the extra complication to make this rule less restrictive is probably
|
||||
** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
|
||||
|
@ -2925,7 +2925,7 @@ static int xferOptimization(
|
|||
** (If the destination is not initially empty, the rowid fields
|
||||
** of index entries might need to change.)
|
||||
**
|
||||
** (2) The destination has a unique index. (The xfer optimization
|
||||
** (2) The destination has a unique index. (The xfer optimization
|
||||
** is unable to test uniqueness.)
|
||||
**
|
||||
** (3) onError is something other than OE_Abort and OE_Rollback.
|
||||
|
@ -3001,14 +3001,14 @@ static int xferOptimization(
|
|||
/* This INSERT command is part of a VACUUM operation, which guarantees
|
||||
** that the destination table is empty. If all indexed columns use
|
||||
** collation sequence BINARY, then it can also be assumed that the
|
||||
** index will be populated by inserting keys in strictly sorted
|
||||
** index will be populated by inserting keys in strictly sorted
|
||||
** order. In this case, instead of seeking within the b-tree as part
|
||||
** of every OP_IdxInsert opcode, an OP_SeekEnd is added before the
|
||||
** OP_IdxInsert to seek to the point within the b-tree where each key
|
||||
** OP_IdxInsert to seek to the point within the b-tree where each key
|
||||
** should be inserted. This is faster.
|
||||
**
|
||||
** If any of the indexed columns use a collation sequence other than
|
||||
** BINARY, this optimization is disabled. This is because the user
|
||||
** BINARY, this optimization is disabled. This is because the user
|
||||
** might change the definition of a collation sequence and then run
|
||||
** a VACUUM command. In that case keys may not be written in strictly
|
||||
** sorted order. */
|
||||
|
@ -3026,9 +3026,9 @@ static int xferOptimization(
|
|||
}
|
||||
if( idxInsFlags!=(OPFLAG_USESEEKRESULT|OPFLAG_PREFORMAT) ){
|
||||
sqlite3VdbeAddOp3(v, OP_RowData, iSrc, regData, 1);
|
||||
if( (db->mDbFlags & DBFLAG_Vacuum)==0
|
||||
&& !HasRowid(pDest)
|
||||
&& IsPrimaryKeyIndex(pDestIdx)
|
||||
if( (db->mDbFlags & DBFLAG_Vacuum)==0
|
||||
&& !HasRowid(pDest)
|
||||
&& IsPrimaryKeyIndex(pDestIdx)
|
||||
){
|
||||
codeWithoutRowidPreupdate(pParse, pDest, iDest, regData);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue