Skip to content

Commit

Permalink
Extend the refactoring into extensions. Clean up stray newlines.
Browse files Browse the repository at this point in the history
FossilOrigin-Name: 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
  • Loading branch information
drh committed Jun 19, 2020
1 parent 1e32bed commit 067b92b
Show file tree
Hide file tree
Showing 54 changed files with 2,267 additions and 485 deletions.
1 change: 0 additions & 1 deletion ext/async/sqlite3async.c
Original file line number Diff line number Diff line change
Expand Up @@ -1704,4 +1704,3 @@ int sqlite3async_control(int op, ...){
}

#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_ASYNCIO) */

1 change: 0 additions & 1 deletion ext/async/sqlite3async.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,3 @@ int sqlite3async_control(int op, ...);
} /* End of the 'extern "C"' block */
#endif
#endif /* ifndef __SQLITEASYNC_H_ */

16 changes: 8 additions & 8 deletions ext/expert/sqlite3expert.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ static int idxProcessOneTrigger(
IdxTable *pTab = pWrite->pTab;
const char *zTab = pTab->zName;
const char *zSql =
"SELECT 'CREATE TEMP' || substr(sql, 7) FROM sqlite_master "
"SELECT 'CREATE TEMP' || substr(sql, 7) FROM sqlite_schema "
"WHERE tbl_name = %Q AND type IN ('table', 'trigger') "
"ORDER BY type;";
sqlite3_stmt *pSelect = 0;
Expand Down Expand Up @@ -1323,12 +1323,12 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
** 2) Create the equivalent virtual table in dbv.
*/
rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg,
"SELECT type, name, sql, 1 FROM sqlite_master "
"SELECT type, name, sql, 1 FROM sqlite_schema "
"WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' "
" UNION ALL "
"SELECT type, name, sql, 2 FROM sqlite_master "
"SELECT type, name, sql, 2 FROM sqlite_schema "
"WHERE type = 'trigger'"
" AND tbl_name IN(SELECT name FROM sqlite_master WHERE type = 'view') "
" AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') "
"ORDER BY 4, 1"
);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){
Expand Down Expand Up @@ -1498,7 +1498,7 @@ static int idxLargestIndex(sqlite3 *db, int *pnMax, char **pzErr){
int rc = SQLITE_OK;
const char *zMax =
"SELECT max(i.seqno) FROM "
" sqlite_master AS s, "
" sqlite_schema AS s, "
" pragma_index_list(s.name) AS l, "
" pragma_index_info(l.name) AS i "
"WHERE s.type = 'table'";
Expand Down Expand Up @@ -1651,7 +1651,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){

const char *zAllIndex =
"SELECT s.rowid, s.name, l.name FROM "
" sqlite_master AS s, "
" sqlite_schema AS s, "
" pragma_index_list(s.name) AS l "
"WHERE s.type = 'table'";
const char *zIndexXInfo =
Expand Down Expand Up @@ -1725,7 +1725,7 @@ static int idxPopulateStat1(sqlite3expert *p, char **pzErr){
sqlite3_free(pCtx);

if( rc==SQLITE_OK ){
rc = sqlite3_exec(p->dbm, "ANALYZE sqlite_master", 0, 0, 0);
rc = sqlite3_exec(p->dbm, "ANALYZE sqlite_schema", 0, 0, 0);
}

sqlite3_exec(p->db, "DROP TABLE IF EXISTS temp."UNIQUE_TABLE_NAME,0,0,0);
Expand Down Expand Up @@ -1764,7 +1764,7 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){
if( rc==SQLITE_OK ){
sqlite3_stmt *pSql;
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
"SELECT sql FROM sqlite_master WHERE name NOT LIKE 'sqlite_%%'"
"SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
" AND sql NOT LIKE 'CREATE VIRTUAL %%'"
);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
Expand Down
2 changes: 0 additions & 2 deletions ext/fts3/README.content
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,3 @@ EXTERNAL CONTENT FTS4 TABLES
only be useful if the full-text index has somehow become corrupt. It is an
error to attempt to rebuild the full-text index maintained by a contentless
FTS4 table.


4 changes: 2 additions & 2 deletions ext/fts3/tool/fts3view.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static int runSql(sqlite3 *db, const char *zFormat, ...){
static void showSchema(sqlite3 *db, const char *zTab){
sqlite3_stmt *pStmt;
pStmt = prepare(db,
"SELECT sql FROM sqlite_master"
"SELECT sql FROM sqlite_schema"
" WHERE name LIKE '%q%%'"
" ORDER BY 1",
zTab);
Expand Down Expand Up @@ -831,7 +831,7 @@ int main(int argc, char **argv){
sqlite3_stmt *pStmt;
int cnt = 0;
pStmt = prepare(db, "SELECT b.sql"
" FROM sqlite_master a, sqlite_master b"
" FROM sqlite_schema a, sqlite_schema b"
" WHERE a.name GLOB '*_segdir'"
" AND b.name=substr(a.name,1,length(a.name)-7)"
" ORDER BY 1");
Expand Down
1 change: 0 additions & 1 deletion ext/icu/sqliteicu.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ int sqlite3IcuInit(sqlite3 *db);
#ifdef __cplusplus
} /* extern "C" */
#endif /* __cplusplus */

2 changes: 0 additions & 2 deletions ext/lsm1/lsm-test/lsmtest1.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,5 +654,3 @@ void test_data_3(
testFree(zName);
}
}


2 changes: 0 additions & 2 deletions ext/lsm1/lsm-test/lsmtest8.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,3 @@ void do_writer_crash_test(const char *zPattern, int *pRc){
}

}


3 changes: 0 additions & 3 deletions ext/lsm1/lsm-test/lsmtest9.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,3 @@ void test_data_4(
testFree(zName);
}
}



4 changes: 0 additions & 4 deletions ext/lsm1/lsm-test/lsmtest_bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,3 @@ int do_bt(int nArg, char **azArg){
sqlite4_buffer_clear(&buf.output);
return 0;
}




2 changes: 1 addition & 1 deletion ext/lsm1/lsm-test/lsmtest_tdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static int sql_begin(TestDb *pTestDb, int iLevel){
/* If there are no transactions at all open, open a read transaction. */
if( pDb->nOpenTrans==0 ){
int rc = sqlite3_exec(pDb->db,
"BEGIN; SELECT * FROM sqlite_master LIMIT 1;" , 0, 0, 0
"BEGIN; SELECT * FROM sqlite_schema LIMIT 1;" , 0, 0, 0
);
if( rc!=0 ) return rc;
pDb->nOpenTrans = 1;
Expand Down
1 change: 0 additions & 1 deletion ext/lsm1/lsm-test/lsmtest_tdb2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,3 @@ int test_mdb_scan(
}

#endif /* HAVE_MDB */

2 changes: 0 additions & 2 deletions ext/lsm1/lsm-test/lsmtest_tdb4.c
Original file line number Diff line number Diff line change
Expand Up @@ -978,5 +978,3 @@ static int bgc_detach(BtDb *pDb){
/*
** End of background checkpointer.
*************************************************************************/


12 changes: 6 additions & 6 deletions ext/misc/btreeinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
** name TEXT, -- Name of table or index for this btree.
** tbl_name TEXT, -- Associated table
** rootpage INT, -- The root page of the btree
** sql TEXT, -- SQL for this btree - from sqlite_master
** sql TEXT, -- SQL for this btree - from sqlite_schema
** hasRowid BOOLEAN, -- True if the btree has a rowid
** nEntry INT, -- Estimated number of entries
** nPage INT, -- Estimated number of pages
Expand All @@ -30,9 +30,9 @@
** zSchema TEXT HIDDEN -- The schema to which this btree belongs
** );
**
** The first 5 fields are taken directly from the sqlite_master table.
** The first 5 fields are taken directly from the sqlite_schema table.
** Considering only the first 5 fields, the only difference between
** this virtual table and the sqlite_master table is that this virtual
** this virtual table and the sqlite_schema table is that this virtual
** table omits all entries that have a 0 or NULL rowid - in other words
** it omits triggers and views.
**
Expand Down Expand Up @@ -88,7 +88,7 @@ typedef struct BinfoCursor BinfoCursor;
/* A cursor for the sqlite_btreeinfo table */
struct BinfoCursor {
sqlite3_vtab_cursor base; /* Base class. Must be first */
sqlite3_stmt *pStmt; /* Query against sqlite_master */
sqlite3_stmt *pStmt; /* Query against sqlite_schema */
int rc; /* Result of previous sqlite_step() call */
int hasRowid; /* hasRowid value. Negative if unknown. */
sqlite3_int64 nEntry; /* nEntry value */
Expand Down Expand Up @@ -242,10 +242,10 @@ static int binfoFilter(
pCsr->zSchema = sqlite3_mprintf("main");
}
zSql = sqlite3_mprintf(
"SELECT 0, 'table','sqlite_master','sqlite_master',1,NULL "
"SELECT 0, 'table','sqlite_schema','sqlite_schema',1,NULL "
"UNION ALL "
"SELECT rowid, type, name, tbl_name, rootpage, sql"
" FROM \"%w\".sqlite_master WHERE rootpage>=1",
" FROM \"%w\".sqlite_schema WHERE rootpage>=1",
pCsr->zSchema);
sqlite3_finalize(pCsr->pStmt);
pCsr->pStmt = 0;
Expand Down
4 changes: 2 additions & 2 deletions ext/misc/completion.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static int completionNext(sqlite3_vtab_cursor *cur){
const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
zSql = sqlite3_mprintf(
"%z%s"
"SELECT name FROM \"%w\".sqlite_master",
"SELECT name FROM \"%w\".sqlite_schema",
zSql, zSep, zDb
);
if( zSql==0 ) return SQLITE_NOMEM;
Expand All @@ -250,7 +250,7 @@ static int completionNext(sqlite3_vtab_cursor *cur){
const char *zDb = (const char*)sqlite3_column_text(pS2, 1);
zSql = sqlite3_mprintf(
"%z%s"
"SELECT pti.name FROM \"%w\".sqlite_master AS sm"
"SELECT pti.name FROM \"%w\".sqlite_schema AS sm"
" JOIN pragma_table_info(sm.name,%Q) AS pti"
" WHERE sm.type='table'",
zSql, zSep, zDb, zDb
Expand Down
14 changes: 7 additions & 7 deletions ext/misc/dbdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
if( strcmp(zTable, "sqlite_sequence")==0 ){
p->xCallback("DELETE FROM sqlite_sequence;\n", p->pArg);
}else if( sqlite3_strglob("sqlite_stat?", zTable)==0 ){
p->xCallback("ANALYZE sqlite_master;\n", p->pArg);
p->xCallback("ANALYZE sqlite_schema;\n", p->pArg);
}else if( strncmp(zTable, "sqlite_", 7)==0 ){
return 0;
}else if( strncmp(zSql, "CREATE VIRTUAL TABLE", 20)==0 ){
Expand All @@ -404,7 +404,7 @@ static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
p->writableSchema = 1;
}
output_formatted(p,
"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"
"INSERT INTO sqlite_schema(type,name,tbl_name,rootpage,sql)"
"VALUES('table','%q','%q',0,'%q');",
zTable, zTable, zSql);
return 0;
Expand Down Expand Up @@ -646,27 +646,27 @@ int sqlite3_db_dump(
xCallback("PRAGMA foreign_keys=OFF;\nBEGIN TRANSACTION;\n", pArg);
if( zTable==0 ){
run_schema_dump_query(&x,
"SELECT name, type, sql FROM \"%w\".sqlite_master "
"SELECT name, type, sql FROM \"%w\".sqlite_schema "
"WHERE sql NOT NULL AND type=='table' AND name!='sqlite_sequence'",
zSchema
);
run_schema_dump_query(&x,
"SELECT name, type, sql FROM \"%w\".sqlite_master "
"SELECT name, type, sql FROM \"%w\".sqlite_schema "
"WHERE name=='sqlite_sequence'", zSchema
);
output_sql_from_query(&x,
"SELECT sql FROM sqlite_master "
"SELECT sql FROM sqlite_schema "
"WHERE sql NOT NULL AND type IN ('index','trigger','view')", 0
);
}else{
run_schema_dump_query(&x,
"SELECT name, type, sql FROM \"%w\".sqlite_master "
"SELECT name, type, sql FROM \"%w\".sqlite_schema "
"WHERE tbl_name=%Q COLLATE nocase AND type=='table'"
" AND sql NOT NULL",
zSchema, zTable
);
output_sql_from_query(&x,
"SELECT sql FROM \"%w\".sqlite_master "
"SELECT sql FROM \"%w\".sqlite_schema "
"WHERE sql NOT NULL"
" AND type IN ('index','trigger','view')"
" AND tbl_name=%Q COLLATE nocase",
Expand Down
2 changes: 1 addition & 1 deletion ext/misc/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
** Usage example:
**
** .load ./explain
** SELECT p2 FROM explain('SELECT * FROM sqlite_master')
** SELECT p2 FROM explain('SELECT * FROM sqlite_schema')
** WHERE opcode='OpenRead';
**
** This module was originally written to help simplify SQLite testing,
Expand Down
2 changes: 1 addition & 1 deletion ext/misc/mmapwarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int sqlite3_mmap_warm(sqlite3 *db, const char *zDb){
if( 0==sqlite3_get_autocommit(db) ) return SQLITE_MISUSE;

/* Open a read-only transaction on the file in question */
zSql = sqlite3_mprintf("BEGIN; SELECT * FROM %s%q%ssqlite_master",
zSql = sqlite3_mprintf("BEGIN; SELECT * FROM %s%q%ssqlite_schema",
(zDb ? "'" : ""), (zDb ? zDb : ""), (zDb ? "'." : "")
);
if( zSql==0 ) return SQLITE_NOMEM;
Expand Down
4 changes: 2 additions & 2 deletions ext/misc/scrub.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ static void scrubBackupOpenSrc(ScrubState *p){
sqlite3_errmsg(p->dbSrc));
return;
}
p->rcErr = sqlite3_exec(p->dbSrc, "SELECT 1 FROM sqlite_master; BEGIN;",
p->rcErr = sqlite3_exec(p->dbSrc, "SELECT 1 FROM sqlite_schema; BEGIN;",
0, 0, 0);
if( p->rcErr ){
scrubBackupErr(p,
Expand Down Expand Up @@ -535,7 +535,7 @@ int sqlite3_scrub_backup(
/* Copy all of the btrees */
scrubBackupBtree(&s, 1, 0);
pStmt = scrubBackupPrepare(&s, s.dbSrc,
"SELECT rootpage FROM sqlite_master WHERE coalesce(rootpage,0)>0");
"SELECT rootpage FROM sqlite_schema WHERE coalesce(rootpage,0)>0");
if( pStmt==0 ) goto scrub_abort;
while( sqlite3_step(pStmt)==SQLITE_ROW ){
i = (u32)sqlite3_column_int(pStmt, 0);
Expand Down
Loading

0 comments on commit 067b92b

Please sign in to comment.