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
96
third_party/sqlite3/sqlite3expert.c
vendored
96
third_party/sqlite3/sqlite3expert.c
vendored
|
@ -17,7 +17,7 @@
|
|||
#include "third_party/sqlite3/sqlite3expert.h"
|
||||
// clang-format off
|
||||
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
#ifndef SQLITE_OMIT_VIRTUALTABLE
|
||||
|
||||
typedef sqlite3_int64 i64;
|
||||
typedef sqlite3_uint64 u64;
|
||||
|
@ -69,7 +69,7 @@ struct IdxScan {
|
|||
};
|
||||
|
||||
/*
|
||||
** Information regarding a single database table. Extracted from
|
||||
** Information regarding a single database table. Extracted from
|
||||
** "PRAGMA table_info" by function idxGetTableInfo().
|
||||
*/
|
||||
struct IdxColumn {
|
||||
|
@ -153,7 +153,7 @@ struct sqlite3expert {
|
|||
|
||||
|
||||
/*
|
||||
** Allocate and return nByte bytes of zeroed memory using sqlite3_malloc().
|
||||
** Allocate and return nByte bytes of zeroed memory using sqlite3_malloc().
|
||||
** If the allocation fails, set *pRc to SQLITE_NOMEM and return NULL.
|
||||
*/
|
||||
static void *idxMalloc(int *pRc, int nByte){
|
||||
|
@ -209,11 +209,11 @@ static int idxHashString(const char *z, int n){
|
|||
/*
|
||||
** If zKey is already present in the hash table, return non-zero and do
|
||||
** nothing. Otherwise, add an entry with key zKey and payload string zVal to
|
||||
** the hash table passed as the second argument.
|
||||
** the hash table passed as the second argument.
|
||||
*/
|
||||
static int idxHashAdd(
|
||||
int *pRc,
|
||||
IdxHash *pHash,
|
||||
int *pRc,
|
||||
IdxHash *pHash,
|
||||
const char *zKey,
|
||||
const char *zVal
|
||||
){
|
||||
|
@ -245,7 +245,7 @@ static int idxHashAdd(
|
|||
}
|
||||
|
||||
/*
|
||||
** If zKey/nKey is present in the hash table, return a pointer to the
|
||||
** If zKey/nKey is present in the hash table, return a pointer to the
|
||||
** hash-entry object.
|
||||
*/
|
||||
static IdxHashEntry *idxHashFind(IdxHash *pHash, const char *zKey, int nKey){
|
||||
|
@ -384,7 +384,7 @@ static char *expertDequote(const char *zIn){
|
|||
return zRet;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** This function is the implementation of both the xConnect and xCreate
|
||||
** methods of the r-tree virtual table.
|
||||
**
|
||||
|
@ -440,7 +440,7 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){
|
|||
int rc = SQLITE_OK;
|
||||
int n = 0;
|
||||
IdxScan *pScan;
|
||||
const int opmask =
|
||||
const int opmask =
|
||||
SQLITE_INDEX_CONSTRAINT_EQ | SQLITE_INDEX_CONSTRAINT_GT |
|
||||
SQLITE_INDEX_CONSTRAINT_LT | SQLITE_INDEX_CONSTRAINT_GE |
|
||||
SQLITE_INDEX_CONSTRAINT_LE;
|
||||
|
@ -457,10 +457,10 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){
|
|||
/* Add the constraints to the IdxScan object */
|
||||
for(i=0; i<pIdxInfo->nConstraint; i++){
|
||||
struct sqlite3_index_constraint *pCons = &pIdxInfo->aConstraint[i];
|
||||
if( pCons->usable
|
||||
&& pCons->iColumn>=0
|
||||
if( pCons->usable
|
||||
&& pCons->iColumn>=0
|
||||
&& p->pTab->aCol[pCons->iColumn].iPk==0
|
||||
&& (pCons->op & opmask)
|
||||
&& (pCons->op & opmask)
|
||||
){
|
||||
IdxConstraint *pNew;
|
||||
const char *zColl = sqlite3_vtab_collation(pIdxInfo, i);
|
||||
|
@ -503,9 +503,9 @@ static int expertBestIndex(sqlite3_vtab *pVtab, sqlite3_index_info *pIdxInfo){
|
|||
}
|
||||
|
||||
static int expertUpdate(
|
||||
sqlite3_vtab *pVtab,
|
||||
int nData,
|
||||
sqlite3_value **azData,
|
||||
sqlite3_vtab *pVtab,
|
||||
int nData,
|
||||
sqlite3_value **azData,
|
||||
sqlite_int64 *pRowid
|
||||
){
|
||||
(void)pVtab;
|
||||
|
@ -515,7 +515,7 @@ static int expertUpdate(
|
|||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Virtual table module xOpen method.
|
||||
*/
|
||||
static int expertOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
|
||||
|
@ -527,7 +527,7 @@ static int expertOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Virtual table module xClose method.
|
||||
*/
|
||||
static int expertClose(sqlite3_vtab_cursor *cur){
|
||||
|
@ -540,7 +540,7 @@ static int expertClose(sqlite3_vtab_cursor *cur){
|
|||
/*
|
||||
** Virtual table module xEof method.
|
||||
**
|
||||
** Return non-zero if the cursor does not currently point to a valid
|
||||
** Return non-zero if the cursor does not currently point to a valid
|
||||
** record (i.e if the scan has finished), or zero otherwise.
|
||||
*/
|
||||
static int expertEof(sqlite3_vtab_cursor *cur){
|
||||
|
@ -548,7 +548,7 @@ static int expertEof(sqlite3_vtab_cursor *cur){
|
|||
return pCsr->pData==0;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Virtual table module xNext method.
|
||||
*/
|
||||
static int expertNext(sqlite3_vtab_cursor *cur){
|
||||
|
@ -567,7 +567,7 @@ static int expertNext(sqlite3_vtab_cursor *cur){
|
|||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Virtual table module xRowid method.
|
||||
*/
|
||||
static int expertRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
|
||||
|
@ -576,7 +576,7 @@ static int expertRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){
|
|||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Virtual table module xColumn method.
|
||||
*/
|
||||
static int expertColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
|
||||
|
@ -589,11 +589,11 @@ static int expertColumn(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){
|
|||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
** Virtual table module xFilter method.
|
||||
*/
|
||||
static int expertFilter(
|
||||
sqlite3_vtab_cursor *cur,
|
||||
sqlite3_vtab_cursor *cur,
|
||||
int idxNum, const char *idxStr,
|
||||
int argc, sqlite3_value **argv
|
||||
){
|
||||
|
@ -748,7 +748,7 @@ static int idxGetTableInfo(
|
|||
}
|
||||
|
||||
/*
|
||||
** This function is a no-op if *pRc is set to anything other than
|
||||
** This function is a no-op if *pRc is set to anything other than
|
||||
** SQLITE_OK when it is called.
|
||||
**
|
||||
** If *pRc is initially set to SQLITE_OK, then the text specified by
|
||||
|
@ -838,7 +838,7 @@ static char *idxAppendColDefn(
|
|||
|
||||
/*
|
||||
** Search database dbm for an index compatible with the one idxCreateFromCons()
|
||||
** would create from arguments pScan, pEq and pTail. If no error occurs and
|
||||
** would create from arguments pScan, pEq and pTail. If no error occurs and
|
||||
** such an index is found, return non-zero. Or, if no such index is found,
|
||||
** return zero.
|
||||
**
|
||||
|
@ -914,7 +914,7 @@ static int idxFindCompatible(
|
|||
static int idxCreateFromCons(
|
||||
sqlite3expert *p,
|
||||
IdxScan *pScan,
|
||||
IdxConstraint *pEq,
|
||||
IdxConstraint *pEq,
|
||||
IdxConstraint *pTail
|
||||
){
|
||||
sqlite3 *dbm = p->dbm;
|
||||
|
@ -943,7 +943,7 @@ static int idxCreateFromCons(
|
|||
h += ((h<<3) + zCols[i]);
|
||||
}
|
||||
zName = sqlite3_mprintf("%s_idx_%08x", zTable, h);
|
||||
if( zName==0 ){
|
||||
if( zName==0 ){
|
||||
rc = SQLITE_NOMEM;
|
||||
}else{
|
||||
if( idxIdentifierRequiresQuotes(zTable) ){
|
||||
|
@ -981,7 +981,7 @@ static int idxFindConstraint(IdxConstraint *pList, IdxConstraint *p){
|
|||
}
|
||||
|
||||
static int idxCreateFromWhere(
|
||||
sqlite3expert *p,
|
||||
sqlite3expert *p,
|
||||
IdxScan *pScan, /* Create indexes for this scan */
|
||||
IdxConstraint *pTail /* range/ORDER BY constraints for inclusion */
|
||||
){
|
||||
|
@ -1016,7 +1016,7 @@ static int idxCreateFromWhere(
|
|||
}
|
||||
|
||||
/*
|
||||
** Create candidate indexes in database [dbm] based on the data in
|
||||
** Create candidate indexes in database [dbm] based on the data in
|
||||
** linked-list pScan.
|
||||
*/
|
||||
static int idxCreateCandidates(sqlite3expert *p){
|
||||
|
@ -1063,7 +1063,7 @@ static void idxScanFree(IdxScan *pScan, IdxScan *pLast){
|
|||
}
|
||||
|
||||
/*
|
||||
** Free all elements of the linked list starting from pStatement up
|
||||
** Free all elements of the linked list starting from pStatement up
|
||||
** until pLast (pLast is not freed).
|
||||
*/
|
||||
static void idxStatementFree(IdxStatement *pStatement, IdxStatement *pLast){
|
||||
|
@ -1141,8 +1141,8 @@ int idxFindIndexes(
|
|||
const char *zIdx = 0;
|
||||
if( i+13<nDetail && memcmp(&zDetail[i], " USING INDEX ", 13)==0 ){
|
||||
zIdx = &zDetail[i+13];
|
||||
}else if( i+22<nDetail
|
||||
&& memcmp(&zDetail[i], " USING COVERING INDEX ", 22)==0
|
||||
}else if( i+22<nDetail
|
||||
&& memcmp(&zDetail[i], " USING COVERING INDEX ", 22)==0
|
||||
){
|
||||
zIdx = &zDetail[i+22];
|
||||
}
|
||||
|
@ -1218,15 +1218,15 @@ static int idxAuthCallback(
|
|||
}
|
||||
|
||||
static int idxProcessOneTrigger(
|
||||
sqlite3expert *p,
|
||||
IdxWrite *pWrite,
|
||||
sqlite3expert *p,
|
||||
IdxWrite *pWrite,
|
||||
char **pzErr
|
||||
){
|
||||
static const char *zInt = UNIQUE_TABLE_NAME;
|
||||
static const char *zDrop = "DROP TABLE " UNIQUE_TABLE_NAME;
|
||||
IdxTable *pTab = pWrite->pTab;
|
||||
const char *zTab = pTab->zName;
|
||||
const char *zSql =
|
||||
const char *zSql =
|
||||
"SELECT 'CREATE TEMP' || substr(sql, 7) FROM sqlite_schema "
|
||||
"WHERE tbl_name = %Q AND type IN ('table', 'trigger') "
|
||||
"ORDER BY type;";
|
||||
|
@ -1267,7 +1267,7 @@ static int idxProcessOneTrigger(
|
|||
int i;
|
||||
zWrite = idxAppendText(&rc, zWrite, "UPDATE %Q SET ", zInt);
|
||||
for(i=0; i<pTab->nCol; i++){
|
||||
zWrite = idxAppendText(&rc, zWrite, "%s%Q=?", i==0 ? "" : ", ",
|
||||
zWrite = idxAppendText(&rc, zWrite, "%s%Q=?", i==0 ? "" : ", ",
|
||||
pTab->aCol[i].zName
|
||||
);
|
||||
}
|
||||
|
@ -1355,14 +1355,14 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
|
|||
/* The statement the vtab will pass to sqlite3_declare_vtab() */
|
||||
zInner = idxAppendText(&rc, 0, "CREATE TABLE x(");
|
||||
for(i=0; i<pTab->nCol; i++){
|
||||
zInner = idxAppendText(&rc, zInner, "%s%Q COLLATE %s",
|
||||
zInner = idxAppendText(&rc, zInner, "%s%Q COLLATE %s",
|
||||
(i==0 ? "" : ", "), pTab->aCol[i].zName, pTab->aCol[i].zColl
|
||||
);
|
||||
}
|
||||
zInner = idxAppendText(&rc, zInner, ")");
|
||||
|
||||
/* The CVT statement to create the vtab */
|
||||
zOuter = idxAppendText(&rc, 0,
|
||||
zOuter = idxAppendText(&rc, 0,
|
||||
"CREATE VIRTUAL TABLE %Q USING expert(%Q)", zName, zInner
|
||||
);
|
||||
if( rc==SQLITE_OK ){
|
||||
|
@ -1500,7 +1500,7 @@ static void idxRemFunc(
|
|||
|
||||
static int idxLargestIndex(sqlite3 *db, int *pnMax, char **pzErr){
|
||||
int rc = SQLITE_OK;
|
||||
const char *zMax =
|
||||
const char *zMax =
|
||||
"SELECT max(i.seqno) FROM "
|
||||
" sqlite_schema AS s, "
|
||||
" pragma_index_list(s.name) AS l, "
|
||||
|
@ -1543,7 +1543,7 @@ static int idxPopulateOneStat1(
|
|||
const char *zComma = zCols==0 ? "" : ", ";
|
||||
const char *zName = (const char*)sqlite3_column_text(pIndexXInfo, 0);
|
||||
const char *zColl = (const char*)sqlite3_column_text(pIndexXInfo, 1);
|
||||
zCols = idxAppendText(&rc, zCols,
|
||||
zCols = idxAppendText(&rc, zCols,
|
||||
"%sx.%Q IS rem(%d, x.%Q) COLLATE %s", zComma, zName, nCol, zName, zColl
|
||||
);
|
||||
zOrder = idxAppendText(&rc, zOrder, "%s%d", zComma, ++nCol);
|
||||
|
@ -1640,13 +1640,13 @@ static int idxBuildSampleTable(sqlite3expert *p, const char *zTab){
|
|||
** indexes have already been created in database sqlite3expert.dbm, this
|
||||
** function populates sqlite_stat1 table in the same database.
|
||||
**
|
||||
** The stat1 data is generated by querying the
|
||||
** The stat1 data is generated by querying the
|
||||
*/
|
||||
static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
|
||||
int rc = SQLITE_OK;
|
||||
int nMax =0;
|
||||
struct IdxRemCtx *pCtx = 0;
|
||||
struct IdxSampleCtx samplectx;
|
||||
struct IdxSampleCtx samplectx;
|
||||
int i;
|
||||
i64 iPrev = -100000;
|
||||
sqlite3_stmt *pAllIndex = 0;
|
||||
|
@ -1658,7 +1658,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
|
|||
" sqlite_schema AS s, "
|
||||
" pragma_index_list(s.name) AS l "
|
||||
"WHERE s.type = 'table'";
|
||||
const char *zIndexXInfo =
|
||||
const char *zIndexXInfo =
|
||||
"SELECT name, coll FROM pragma_index_xinfo(?) WHERE key";
|
||||
const char *zWrite = "INSERT INTO sqlite_stat1 VALUES(?, ?, ?)";
|
||||
|
||||
|
@ -1714,7 +1714,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
|
|||
iPrev = iRowid;
|
||||
}
|
||||
if( rc==SQLITE_OK && p->iSample<100 ){
|
||||
rc = sqlite3_exec(p->dbv,
|
||||
rc = sqlite3_exec(p->dbv,
|
||||
"DROP TABLE IF EXISTS temp." UNIQUE_TABLE_NAME, 0,0,0
|
||||
);
|
||||
}
|
||||
|
@ -1764,12 +1764,12 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){
|
|||
sqlite3_db_config(pNew->dbm, SQLITE_DBCONFIG_TRIGGER_EQP, 1, (int*)0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Copy the entire schema of database [db] into [dbm]. */
|
||||
if( rc==SQLITE_OK ){
|
||||
sqlite3_stmt *pSql;
|
||||
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
|
||||
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
|
||||
"SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
|
||||
" AND sql NOT LIKE 'CREATE VIRTUAL %%'"
|
||||
);
|
||||
|
@ -1890,8 +1890,8 @@ int sqlite3_expert_analyze(sqlite3expert *p, char **pzErr){
|
|||
|
||||
/* Formulate the EXPERT_REPORT_CANDIDATES text */
|
||||
for(pEntry=p->hIdx.pFirst; pEntry; pEntry=pEntry->pNext){
|
||||
p->zCandidates = idxAppendText(&rc, p->zCandidates,
|
||||
"%s;%s%s\n", pEntry->zVal,
|
||||
p->zCandidates = idxAppendText(&rc, p->zCandidates,
|
||||
"%s;%s%s\n", pEntry->zVal,
|
||||
pEntry->zVal2 ? " -- stat1: " : "", pEntry->zVal2
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue