Fossil SCM

Use the schema-table naming convention appropriate for SQLite 3.33.0.

drh 2020-06-19 16:44 trunk
Commit 22645e1f0606b5ef4bd6351a97d5a88b78d01484d50fd61cb46d8d8829f01266
+1 -1
--- src/bundle.c
+++ src/bundle.c
@@ -25,11 +25,11 @@
2525
** SQL code used to initialize the schema of a bundle.
2626
**
2727
** The bblob.delta field can be an integer, a text string, or NULL.
2828
** If an integer, then the corresponding blobid is the delta basis.
2929
** If a text string, then that string is a SHA1 hash for the delta
30
-** basis, which is presumably in the master repository. If NULL, then
30
+** basis, which is presumably in the main repository. If NULL, then
3131
** data contains content without delta compression.
3232
*/
3333
static const char zBundleInit[] =
3434
@ CREATE TABLE IF NOT EXISTS "%w".bconfig(
3535
@ bcname TEXT,
3636
--- src/bundle.c
+++ src/bundle.c
@@ -25,11 +25,11 @@
25 ** SQL code used to initialize the schema of a bundle.
26 **
27 ** The bblob.delta field can be an integer, a text string, or NULL.
28 ** If an integer, then the corresponding blobid is the delta basis.
29 ** If a text string, then that string is a SHA1 hash for the delta
30 ** basis, which is presumably in the master repository. If NULL, then
31 ** data contains content without delta compression.
32 */
33 static const char zBundleInit[] =
34 @ CREATE TABLE IF NOT EXISTS "%w".bconfig(
35 @ bcname TEXT,
36
--- src/bundle.c
+++ src/bundle.c
@@ -25,11 +25,11 @@
25 ** SQL code used to initialize the schema of a bundle.
26 **
27 ** The bblob.delta field can be an integer, a text string, or NULL.
28 ** If an integer, then the corresponding blobid is the delta basis.
29 ** If a text string, then that string is a SHA1 hash for the delta
30 ** basis, which is presumably in the main repository. If NULL, then
31 ** data contains content without delta compression.
32 */
33 static const char zBundleInit[] =
34 @ CREATE TABLE IF NOT EXISTS "%w".bconfig(
35 @ bcname TEXT,
36
+2 -2
--- src/db.c
+++ src/db.c
@@ -1325,11 +1325,11 @@
13251325
** zDbName is the name of a database file. Attach zDbName using
13261326
** the name zLabel.
13271327
*/
13281328
void db_attach(const char *zDbName, const char *zLabel){
13291329
Blob key;
1330
- if( db_table_exists(zLabel,"sqlite_master") ) return;
1330
+ if( db_table_exists(zLabel,"sqlite_schema") ) return;
13311331
blob_init(&key, 0, 0);
13321332
db_maybe_obtain_encryption_key(zDbName, &key);
13331333
if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
13341334
char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
13351335
zDbName, zLabel, blob_str(&key));
@@ -3992,11 +3992,11 @@
39923992
int dryRun = find_option("dry-run", "n", 0)!=0;
39933993
for(i=2; i<g.argc; i++){
39943994
db_open_or_attach(g.argv[i], "main");
39953995
blob_init(&allSql, "BEGIN;\n", -1);
39963996
db_prepare(&q,
3997
- "SELECT name, sql FROM main.sqlite_master "
3997
+ "SELECT name, sql FROM main.sqlite_schema "
39983998
" WHERE type='table' AND sql NOT LIKE '%%WITHOUT ROWID%%'"
39993999
" AND name IN ('global_config','shun','concealed','config',"
40004000
" 'plink','tagxref','backlink','vcache');"
40014001
);
40024002
while( db_step(&q)==SQLITE_ROW ){
40034003
--- src/db.c
+++ src/db.c
@@ -1325,11 +1325,11 @@
1325 ** zDbName is the name of a database file. Attach zDbName using
1326 ** the name zLabel.
1327 */
1328 void db_attach(const char *zDbName, const char *zLabel){
1329 Blob key;
1330 if( db_table_exists(zLabel,"sqlite_master") ) return;
1331 blob_init(&key, 0, 0);
1332 db_maybe_obtain_encryption_key(zDbName, &key);
1333 if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
1334 char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
1335 zDbName, zLabel, blob_str(&key));
@@ -3992,11 +3992,11 @@
3992 int dryRun = find_option("dry-run", "n", 0)!=0;
3993 for(i=2; i<g.argc; i++){
3994 db_open_or_attach(g.argv[i], "main");
3995 blob_init(&allSql, "BEGIN;\n", -1);
3996 db_prepare(&q,
3997 "SELECT name, sql FROM main.sqlite_master "
3998 " WHERE type='table' AND sql NOT LIKE '%%WITHOUT ROWID%%'"
3999 " AND name IN ('global_config','shun','concealed','config',"
4000 " 'plink','tagxref','backlink','vcache');"
4001 );
4002 while( db_step(&q)==SQLITE_ROW ){
4003
--- src/db.c
+++ src/db.c
@@ -1325,11 +1325,11 @@
1325 ** zDbName is the name of a database file. Attach zDbName using
1326 ** the name zLabel.
1327 */
1328 void db_attach(const char *zDbName, const char *zLabel){
1329 Blob key;
1330 if( db_table_exists(zLabel,"sqlite_schema") ) return;
1331 blob_init(&key, 0, 0);
1332 db_maybe_obtain_encryption_key(zDbName, &key);
1333 if( fossil_getenv("FOSSIL_USE_SEE_TEXTKEY")==0 ){
1334 char *zCmd = sqlite3_mprintf("ATTACH DATABASE %Q AS %Q KEY %Q",
1335 zDbName, zLabel, blob_str(&key));
@@ -3992,11 +3992,11 @@
3992 int dryRun = find_option("dry-run", "n", 0)!=0;
3993 for(i=2; i<g.argc; i++){
3994 db_open_or_attach(g.argv[i], "main");
3995 blob_init(&allSql, "BEGIN;\n", -1);
3996 db_prepare(&q,
3997 "SELECT name, sql FROM main.sqlite_schema "
3998 " WHERE type='table' AND sql NOT LIKE '%%WITHOUT ROWID%%'"
3999 " AND name IN ('global_config','shun','concealed','config',"
4000 " 'plink','tagxref','backlink','vcache');"
4001 );
4002 while( db_step(&q)==SQLITE_ROW ){
4003
+2 -2
--- src/main.c
+++ src/main.c
@@ -673,12 +673,12 @@
673673
}
674674
}
675675
#endif
676676
677677
fossil_limit_memory(1);
678
- if( sqlite3_libversion_number()<3014000 ){
679
- fossil_panic("Unsuitable SQLite version %s, must be at least 3.14.0",
678
+ if( sqlite3_libversion_number()<3033000 ){
679
+ fossil_panic("Unsuitable SQLite version %s, must be at least 3.33.0",
680680
sqlite3_libversion());
681681
}
682682
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
683683
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
684684
memset(&g, 0, sizeof(g));
685685
--- src/main.c
+++ src/main.c
@@ -673,12 +673,12 @@
673 }
674 }
675 #endif
676
677 fossil_limit_memory(1);
678 if( sqlite3_libversion_number()<3014000 ){
679 fossil_panic("Unsuitable SQLite version %s, must be at least 3.14.0",
680 sqlite3_libversion());
681 }
682 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
683 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
684 memset(&g, 0, sizeof(g));
685
--- src/main.c
+++ src/main.c
@@ -673,12 +673,12 @@
673 }
674 }
675 #endif
676
677 fossil_limit_memory(1);
678 if( sqlite3_libversion_number()<3033000 ){
679 fossil_panic("Unsuitable SQLite version %s, must be at least 3.33.0",
680 sqlite3_libversion());
681 }
682 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
683 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
684 memset(&g, 0, sizeof(g));
685
+3 -3
--- src/rebuild.c
+++ src/rebuild.c
@@ -144,11 +144,11 @@
144144
** Update the repository schema for Fossil version 2.0. (2017-02-28)
145145
** (1) Change the CHECK constraint on BLOB.UUID so that the length
146146
** is greater than or equal to 40, not exactly equal to 40.
147147
*/
148148
void rebuild_schema_update_2_0(void){
149
- char *z = db_text(0, "SELECT sql FROM repository.sqlite_master"
149
+ char *z = db_text(0, "SELECT sql FROM repository.sqlite_schema"
150150
" WHERE name='blob'");
151151
if( z ){
152152
/* Search for: length(uuid)==40
153153
** 0123456789 12345 */
154154
int i;
@@ -155,11 +155,11 @@
155155
for(i=10; z[i]; i++){
156156
if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){
157157
z[i] = '>';
158158
db_multi_exec(
159159
"PRAGMA writable_schema=ON;"
160
- "UPDATE repository.sqlite_master SET sql=%Q WHERE name LIKE 'blob';"
160
+ "UPDATE repository.sqlite_schema SET sql=%Q WHERE name LIKE 'blob';"
161161
"PRAGMA writable_schema=OFF;",
162162
z
163163
);
164164
break;
165165
}
@@ -383,11 +383,11 @@
383383
}
384384
alert_triggers_disable();
385385
rebuild_update_schema();
386386
blob_init(&sql, 0, 0);
387387
db_prepare(&q,
388
- "SELECT name FROM sqlite_master /*scan*/"
388
+ "SELECT name FROM sqlite_schema /*scan*/"
389389
" WHERE type='table'"
390390
" AND name NOT IN ('admin_log', 'blob','delta','rcvfrom','user','alias',"
391391
"'config','shun','private','reportfmt',"
392392
"'concealed','accesslog','modreq',"
393393
"'purgeevent','purgeitem','unversioned',"
394394
--- src/rebuild.c
+++ src/rebuild.c
@@ -144,11 +144,11 @@
144 ** Update the repository schema for Fossil version 2.0. (2017-02-28)
145 ** (1) Change the CHECK constraint on BLOB.UUID so that the length
146 ** is greater than or equal to 40, not exactly equal to 40.
147 */
148 void rebuild_schema_update_2_0(void){
149 char *z = db_text(0, "SELECT sql FROM repository.sqlite_master"
150 " WHERE name='blob'");
151 if( z ){
152 /* Search for: length(uuid)==40
153 ** 0123456789 12345 */
154 int i;
@@ -155,11 +155,11 @@
155 for(i=10; z[i]; i++){
156 if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){
157 z[i] = '>';
158 db_multi_exec(
159 "PRAGMA writable_schema=ON;"
160 "UPDATE repository.sqlite_master SET sql=%Q WHERE name LIKE 'blob';"
161 "PRAGMA writable_schema=OFF;",
162 z
163 );
164 break;
165 }
@@ -383,11 +383,11 @@
383 }
384 alert_triggers_disable();
385 rebuild_update_schema();
386 blob_init(&sql, 0, 0);
387 db_prepare(&q,
388 "SELECT name FROM sqlite_master /*scan*/"
389 " WHERE type='table'"
390 " AND name NOT IN ('admin_log', 'blob','delta','rcvfrom','user','alias',"
391 "'config','shun','private','reportfmt',"
392 "'concealed','accesslog','modreq',"
393 "'purgeevent','purgeitem','unversioned',"
394
--- src/rebuild.c
+++ src/rebuild.c
@@ -144,11 +144,11 @@
144 ** Update the repository schema for Fossil version 2.0. (2017-02-28)
145 ** (1) Change the CHECK constraint on BLOB.UUID so that the length
146 ** is greater than or equal to 40, not exactly equal to 40.
147 */
148 void rebuild_schema_update_2_0(void){
149 char *z = db_text(0, "SELECT sql FROM repository.sqlite_schema"
150 " WHERE name='blob'");
151 if( z ){
152 /* Search for: length(uuid)==40
153 ** 0123456789 12345 */
154 int i;
@@ -155,11 +155,11 @@
155 for(i=10; z[i]; i++){
156 if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){
157 z[i] = '>';
158 db_multi_exec(
159 "PRAGMA writable_schema=ON;"
160 "UPDATE repository.sqlite_schema SET sql=%Q WHERE name LIKE 'blob';"
161 "PRAGMA writable_schema=OFF;",
162 z
163 );
164 break;
165 }
@@ -383,11 +383,11 @@
383 }
384 alert_triggers_disable();
385 rebuild_update_schema();
386 blob_init(&sql, 0, 0);
387 db_prepare(&q,
388 "SELECT name FROM sqlite_schema /*scan*/"
389 " WHERE type='table'"
390 " AND name NOT IN ('admin_log', 'blob','delta','rcvfrom','user','alias',"
391 "'config','shun','private','reportfmt',"
392 "'concealed','accesslog','modreq',"
393 "'purgeevent','purgeitem','unversioned',"
394
+2 -2
--- src/report.c
+++ src/report.c
@@ -511,13 +511,13 @@
511511
** Output a bunch of text that provides information about report
512512
** formats
513513
*/
514514
static void report_format_hints(void){
515515
char *zSchema;
516
- zSchema = db_text(0,"SELECT sql FROM sqlite_master WHERE name='ticket'");
516
+ zSchema = db_text(0,"SELECT sql FROM sqlite_schema WHERE name='ticket'");
517517
if( zSchema==0 ){
518
- zSchema = db_text(0,"SELECT sql FROM repository.sqlite_master"
518
+ zSchema = db_text(0,"SELECT sql FROM repository.sqlite_schema"
519519
" WHERE name='ticket'");
520520
}
521521
@ <hr /><h3>TICKET Schema</h3>
522522
@ <blockquote><pre>
523523
@ %h(zSchema)
524524
--- src/report.c
+++ src/report.c
@@ -511,13 +511,13 @@
511 ** Output a bunch of text that provides information about report
512 ** formats
513 */
514 static void report_format_hints(void){
515 char *zSchema;
516 zSchema = db_text(0,"SELECT sql FROM sqlite_master WHERE name='ticket'");
517 if( zSchema==0 ){
518 zSchema = db_text(0,"SELECT sql FROM repository.sqlite_master"
519 " WHERE name='ticket'");
520 }
521 @ <hr /><h3>TICKET Schema</h3>
522 @ <blockquote><pre>
523 @ %h(zSchema)
524
--- src/report.c
+++ src/report.c
@@ -511,13 +511,13 @@
511 ** Output a bunch of text that provides information about report
512 ** formats
513 */
514 static void report_format_hints(void){
515 char *zSchema;
516 zSchema = db_text(0,"SELECT sql FROM sqlite_schema WHERE name='ticket'");
517 if( zSchema==0 ){
518 zSchema = db_text(0,"SELECT sql FROM repository.sqlite_schema"
519 " WHERE name='ticket'");
520 }
521 @ <hr /><h3>TICKET Schema</h3>
522 @ <blockquote><pre>
523 @ %h(zSchema)
524
+2 -2
--- src/setup.c
+++ src/setup.c
@@ -1445,16 +1445,16 @@
14451445
@ <input type="submit" name="tablelist" value="List Tables">
14461446
@ <input type="submit" name="configtab" value="CONFIG Table Query">
14471447
@ </form>
14481448
if( P("schema") ){
14491449
zQ = sqlite3_mprintf(
1450
- "SELECT sql FROM repository.sqlite_master"
1450
+ "SELECT sql FROM repository.sqlite_sqlite"
14511451
" WHERE sql IS NOT NULL ORDER BY name");
14521452
go = 1;
14531453
}else if( P("tablelist") ){
14541454
zQ = sqlite3_mprintf(
1455
- "SELECT name FROM repository.sqlite_master WHERE type='table'"
1455
+ "SELECT name FROM repository.sqlite_schema WHERE type='table'"
14561456
" ORDER BY name");
14571457
go = 1;
14581458
}
14591459
if( go ){
14601460
sqlite3_stmt *pStmt;
14611461
--- src/setup.c
+++ src/setup.c
@@ -1445,16 +1445,16 @@
1445 @ <input type="submit" name="tablelist" value="List Tables">
1446 @ <input type="submit" name="configtab" value="CONFIG Table Query">
1447 @ </form>
1448 if( P("schema") ){
1449 zQ = sqlite3_mprintf(
1450 "SELECT sql FROM repository.sqlite_master"
1451 " WHERE sql IS NOT NULL ORDER BY name");
1452 go = 1;
1453 }else if( P("tablelist") ){
1454 zQ = sqlite3_mprintf(
1455 "SELECT name FROM repository.sqlite_master WHERE type='table'"
1456 " ORDER BY name");
1457 go = 1;
1458 }
1459 if( go ){
1460 sqlite3_stmt *pStmt;
1461
--- src/setup.c
+++ src/setup.c
@@ -1445,16 +1445,16 @@
1445 @ <input type="submit" name="tablelist" value="List Tables">
1446 @ <input type="submit" name="configtab" value="CONFIG Table Query">
1447 @ </form>
1448 if( P("schema") ){
1449 zQ = sqlite3_mprintf(
1450 "SELECT sql FROM repository.sqlite_sqlite"
1451 " WHERE sql IS NOT NULL ORDER BY name");
1452 go = 1;
1453 }else if( P("tablelist") ){
1454 zQ = sqlite3_mprintf(
1455 "SELECT name FROM repository.sqlite_schema WHERE type='table'"
1456 " ORDER BY name");
1457 go = 1;
1458 }
1459 if( go ){
1460 sqlite3_stmt *pStmt;
1461
+3 -3
--- src/stat.c
+++ src/stat.c
@@ -512,11 +512,11 @@
512512
style_submenu_element("URLs", "urllist");
513513
if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
514514
style_submenu_element("Table Sizes", "repo-tabsize");
515515
}
516516
blob_init(&sql,
517
- "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
517
+ "SELECT sql FROM repository.sqlite_schema WHERE sql IS NOT NULL", -1);
518518
if( zArg ){
519519
style_submenu_element("All", "repo_schema");
520520
blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
521521
}
522522
blob_appendf(&sql, " ORDER BY tbl_name, type<>'table', name");
@@ -603,11 +603,11 @@
603603
style_submenu_element("Schema", "repo_schema");
604604
}
605605
db_multi_exec(
606606
"CREATE TEMP TABLE trans(name TEXT PRIMARY KEY,tabname TEXT)WITHOUT ROWID;"
607607
"INSERT INTO trans(name,tabname)"
608
- " SELECT name, tbl_name FROM repository.sqlite_master;"
608
+ " SELECT name, tbl_name FROM repository.sqlite_schema;"
609609
"CREATE TEMP TABLE piechart(amt REAL, label TEXT);"
610610
"INSERT INTO piechart(amt,label)"
611611
" SELECT sum(pageno),"
612612
" coalesce((SELECT tabname FROM trans WHERE trans.name=dbstat.name),name)"
613613
" FROM dbstat('repository',TRUE)"
@@ -629,11 +629,11 @@
629629
630630
if( g.localOpen ){
631631
db_multi_exec(
632632
"DELETE FROM trans;"
633633
"INSERT INTO trans(name,tabname)"
634
- " SELECT name, tbl_name FROM localdb.sqlite_master;"
634
+ " SELECT name, tbl_name FROM localdb.sqlite_schema;"
635635
"DELETE FROM piechart;"
636636
"INSERT INTO piechart(amt,label)"
637637
" SELECT sum(pageno), "
638638
" coalesce((SELECT tabname FROM trans WHERE trans.name=dbstat.name),name)"
639639
" FROM dbstat('localdb',TRUE)"
640640
--- src/stat.c
+++ src/stat.c
@@ -512,11 +512,11 @@
512 style_submenu_element("URLs", "urllist");
513 if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
514 style_submenu_element("Table Sizes", "repo-tabsize");
515 }
516 blob_init(&sql,
517 "SELECT sql FROM repository.sqlite_master WHERE sql IS NOT NULL", -1);
518 if( zArg ){
519 style_submenu_element("All", "repo_schema");
520 blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
521 }
522 blob_appendf(&sql, " ORDER BY tbl_name, type<>'table', name");
@@ -603,11 +603,11 @@
603 style_submenu_element("Schema", "repo_schema");
604 }
605 db_multi_exec(
606 "CREATE TEMP TABLE trans(name TEXT PRIMARY KEY,tabname TEXT)WITHOUT ROWID;"
607 "INSERT INTO trans(name,tabname)"
608 " SELECT name, tbl_name FROM repository.sqlite_master;"
609 "CREATE TEMP TABLE piechart(amt REAL, label TEXT);"
610 "INSERT INTO piechart(amt,label)"
611 " SELECT sum(pageno),"
612 " coalesce((SELECT tabname FROM trans WHERE trans.name=dbstat.name),name)"
613 " FROM dbstat('repository',TRUE)"
@@ -629,11 +629,11 @@
629
630 if( g.localOpen ){
631 db_multi_exec(
632 "DELETE FROM trans;"
633 "INSERT INTO trans(name,tabname)"
634 " SELECT name, tbl_name FROM localdb.sqlite_master;"
635 "DELETE FROM piechart;"
636 "INSERT INTO piechart(amt,label)"
637 " SELECT sum(pageno), "
638 " coalesce((SELECT tabname FROM trans WHERE trans.name=dbstat.name),name)"
639 " FROM dbstat('localdb',TRUE)"
640
--- src/stat.c
+++ src/stat.c
@@ -512,11 +512,11 @@
512 style_submenu_element("URLs", "urllist");
513 if( sqlite3_compileoption_used("ENABLE_DBSTAT_VTAB") ){
514 style_submenu_element("Table Sizes", "repo-tabsize");
515 }
516 blob_init(&sql,
517 "SELECT sql FROM repository.sqlite_schema WHERE sql IS NOT NULL", -1);
518 if( zArg ){
519 style_submenu_element("All", "repo_schema");
520 blob_appendf(&sql, " AND (tbl_name=%Q OR name=%Q)", zArg, zArg);
521 }
522 blob_appendf(&sql, " ORDER BY tbl_name, type<>'table', name");
@@ -603,11 +603,11 @@
603 style_submenu_element("Schema", "repo_schema");
604 }
605 db_multi_exec(
606 "CREATE TEMP TABLE trans(name TEXT PRIMARY KEY,tabname TEXT)WITHOUT ROWID;"
607 "INSERT INTO trans(name,tabname)"
608 " SELECT name, tbl_name FROM repository.sqlite_schema;"
609 "CREATE TEMP TABLE piechart(amt REAL, label TEXT);"
610 "INSERT INTO piechart(amt,label)"
611 " SELECT sum(pageno),"
612 " coalesce((SELECT tabname FROM trans WHERE trans.name=dbstat.name),name)"
613 " FROM dbstat('repository',TRUE)"
@@ -629,11 +629,11 @@
629
630 if( g.localOpen ){
631 db_multi_exec(
632 "DELETE FROM trans;"
633 "INSERT INTO trans(name,tabname)"
634 " SELECT name, tbl_name FROM localdb.sqlite_schema;"
635 "DELETE FROM piechart;"
636 "INSERT INTO piechart(amt,label)"
637 " SELECT sum(pageno), "
638 " coalesce((SELECT tabname FROM trans WHERE trans.name=dbstat.name),name)"
639 " FROM dbstat('localdb',TRUE)"
640

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button