Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Rig the aux-schema checking so that it accepts a range of schema values. Add the BASEID field to the PLINK table, but continue to allow older versions of the PLINK table so that "rebuild" is not require. The schema will automatically update on the next "rebuild". |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5dd8b2dabead37a4c5f18fa2aa188fbb |
User & Date: | drh 2014-11-28 15:36:36 |
Context
2014-11-28
| ||
17:23 | Add the "files_of_checkin" virtual table. ... (check-in: 7a588fe6 user: drh tags: trunk) | |
15:46 | Incorporate all recent trunk enhancements. ... (check-in: 368f82a2 user: drh tags: DBP-workflow) | |
15:36 | Rig the aux-schema checking so that it accepts a range of schema values. Add the BASEID field to the PLINK table, but continue to allow older versions of the PLINK table so that "rebuild" is not require. The schema will automatically update on the next "rebuild". ... (check-in: 5dd8b2da user: drh tags: trunk) | |
15:33 | Minor tweaks to the aux-schema management logic. ... (Closed-Leaf check-in: a7caaea5 user: drh tags: baseline-in-plink) | |
15:11 | Restore the built-in SQLite to version 3.8.8 after fixing the fragmentation size corruption problem. ... (check-in: 21b30fc0 user: drh tags: trunk) | |
Changes
Changes to src/clone.c.
︙ | ︙ | |||
162 163 164 165 166 167 168 | db_create_repository(g.argv[3]); db_open_repository(g.argv[3]); db_begin_transaction(); db_record_repository_filename(g.argv[3]); db_initial_setup(0, 0, zDefaultUser, 0); user_select(); db_set("content-schema", CONTENT_SCHEMA, 0); | | | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | db_create_repository(g.argv[3]); db_open_repository(g.argv[3]); db_begin_transaction(); db_record_repository_filename(g.argv[3]); db_initial_setup(0, 0, zDefaultUser, 0); user_select(); db_set("content-schema", CONTENT_SCHEMA, 0); db_set("aux-schema", AUX_SCHEMA_MAX, 0); db_set("rebuilt", get_version(), 0); remember_or_get_http_auth(zHttpAuth, urlFlags & URL_REMEMBER, g.argv[2]); url_remember(); if( g.zSSLIdentity!=0 ){ /* If the --ssl-identity option was specified, store it as a setting */ Blob fn; blob_zero(&fn); |
︙ | ︙ |
Changes to src/db.c.
︙ | ︙ | |||
1116 1117 1118 1119 1120 1121 1122 | return zDb; } /* ** Return TRUE if the schema is out-of-date */ int db_schema_is_outofdate(void){ | < | > | | | | | | 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 | return zDb; } /* ** Return TRUE if the schema is out-of-date */ int db_schema_is_outofdate(void){ if( g.zAuxSchema==0 ) g.zAuxSchema = db_get("aux-schema",""); return strcmp(g.zAuxSchema,AUX_SCHEMA_MIN)<0 || strcmp(g.zAuxSchema,AUX_SCHEMA_MAX)>0; } /* ** Return true if the database is writeable */ int db_is_writeable(const char *zName){ return g.db!=0 && !sqlite3_db_readonly(g.db, db_name(zName)); } /* ** Verify that the repository schema is correct. If it is not correct, ** issue a fatal error and die. */ void db_verify_schema(void){ if( db_schema_is_outofdate() ){ #ifdef FOSSIL_ENABLE_JSON g.json.resultCode = FSL_JSON_E_DB_NEEDS_REBUILD; #endif fossil_warning("incorrect repository schema version: " "current repository schema version is \"%s\" " "but need versions between \"%s\" and \"%s\".", g.zAuxSchema, AUX_SCHEMA_MIN, AUX_SCHEMA_MAX); fossil_fatal("run \"fossil rebuild\" to fix this problem"); } } /* ** COMMAND: test-move-repository |
︙ | ︙ | |||
1392 1393 1394 1395 1396 1397 1398 | int makeServerCodes /* True to make new server & project codes */ ){ char *zDate; Blob hash; Blob manifest; db_set("content-schema", CONTENT_SCHEMA, 0); | | | 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 | int makeServerCodes /* True to make new server & project codes */ ){ char *zDate; Blob hash; Blob manifest; db_set("content-schema", CONTENT_SCHEMA, 0); db_set("aux-schema", AUX_SCHEMA_MAX, 0); db_set("rebuilt", get_version(), 0); if( makeServerCodes ){ db_setup_server_and_project_codes(0); } if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0); if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0); if( !db_is_global("timeline-plaintext") ){ |
︙ | ︙ |
Changes to src/main.c.
︙ | ︙ | |||
123 124 125 126 127 128 129 130 131 132 133 134 135 136 | int argc; char **argv; /* Command-line arguments to the program */ char *nameOfExe; /* Full path of executable. */ const char *zErrlog; /* Log errors to this file, if not NULL */ int isConst; /* True if the output is unchanging & cacheable */ const char *zVfsName; /* The VFS to use for database connections */ sqlite3 *db; /* The connection to the databases */ sqlite3 *dbConfig; /* Separate connection for global_config table */ int useAttach; /* True if global_config is attached to repository */ const char *zConfigDbName;/* Path of the config database. NULL if not open */ sqlite3_int64 now; /* Seconds since 1970 */ int repositoryOpen; /* True if the main repository database is open */ char *zRepositoryOption; /* Most recent cached repository option value */ char *zRepositoryName; /* Name of the repository database */ char *zLocalDbName; /* Name of the local database */ | > | 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | int argc; char **argv; /* Command-line arguments to the program */ char *nameOfExe; /* Full path of executable. */ const char *zErrlog; /* Log errors to this file, if not NULL */ int isConst; /* True if the output is unchanging & cacheable */ const char *zVfsName; /* The VFS to use for database connections */ sqlite3 *db; /* The connection to the databases */ sqlite3 *dbConfig; /* Separate connection for global_config table */ char *zAuxSchema; /* Main repository aux-schema */ int useAttach; /* True if global_config is attached to repository */ const char *zConfigDbName;/* Path of the config database. NULL if not open */ sqlite3_int64 now; /* Seconds since 1970 */ int repositoryOpen; /* True if the main repository database is open */ char *zRepositoryOption; /* Most recent cached repository option value */ char *zRepositoryName; /* Name of the repository database */ char *zLocalDbName; /* Name of the local database */ |
︙ | ︙ | |||
968 969 970 971 972 973 974 | #if defined(FOSSIL_ENABLE_TCL) int rc; const char *zRc; #endif fossil_print("Compiled on %s %s using %s (%d-bit)\n", __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); fossil_print("SQLite %s %.30s\n", sqlite3_libversion(), sqlite3_sourceid()); | | | 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | #if defined(FOSSIL_ENABLE_TCL) int rc; const char *zRc; #endif fossil_print("Compiled on %s %s using %s (%d-bit)\n", __DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8); fossil_print("SQLite %s %.30s\n", sqlite3_libversion(), sqlite3_sourceid()); fossil_print("Schema version %s\n", AUX_SCHEMA_MAX); #if defined(FOSSIL_ENABLE_MINIZ) fossil_print("miniz %s, loaded %s\n", MZ_VERSION, mz_version()); #else fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion()); #endif #if defined(FOSSIL_ENABLE_SSL) fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION)); |
︙ | ︙ |
Changes to src/manifest.c.
︙ | ︙ | |||
1772 1773 1774 1775 1776 1777 1778 1779 1780 | if( p->type==CFTYPE_MANIFEST ){ if( permitHooks ){ zScript = xfer_commit_code(); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); } if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){ char *zCom; for(i=0; i<p->nParent; i++){ int pid = uuid_to_rid(p->azParent[i], 1); | > > > > > > > > > > > > > > > > > > | | > > | 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 | if( p->type==CFTYPE_MANIFEST ){ if( permitHooks ){ zScript = xfer_commit_code(); zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); } if( !db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){ char *zCom; char zBaseId[30]; if( p->zBaseline ){ sqlite3_snprintf(sizeof(zBaseId), zBaseId, "%d", uuid_to_rid(p->zBaseline,1)); }else{ sqlite3_snprintf(sizeof(zBaseId), zBaseId, "NULL"); } (void)db_schema_is_outofdate(); /* Make sure g.zAuxSchema is initialized */ for(i=0; i<p->nParent; i++){ int pid = uuid_to_rid(p->azParent[i], 1); if( strcmp(g.zAuxSchema,"2014-11-24 20:35")>=0 ){ /* Support for PLINK.BASEID added on 2014-11-24 */ db_multi_exec( "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime, baseid)" "VALUES(%d, %d, %d, %.17g, %s)", pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/); }else{ /* Continue to work with older schema to avoid an unnecessary ** rebuild */ db_multi_exec( "INSERT OR IGNORE INTO plink(pid, cid, isprim, mtime)" "VALUES(%d, %d, %d, %.17g)", pid, rid, i==0, p->rDate); } if( i==0 ){ add_mlink(pid, 0, rid, p); parentid = pid; } } db_prepare(&q, "SELECT cid FROM plink WHERE pid=%d AND isprim", rid); while( db_step(&q)==SQLITE_ROW ){ |
︙ | ︙ |
Changes to src/rebuild.c.
︙ | ︙ | |||
589 590 591 592 593 594 595 | ttyOutput = 1; errCnt = rebuild_db(randomizeFlag, 1, doClustering); reconstruct_private_table(); db_multi_exec( "REPLACE INTO config(name,value,mtime) VALUES('content-schema',%Q,now());" "REPLACE INTO config(name,value,mtime) VALUES('aux-schema',%Q,now());" "REPLACE INTO config(name,value,mtime) VALUES('rebuilt',%Q,now());", | | | 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | ttyOutput = 1; errCnt = rebuild_db(randomizeFlag, 1, doClustering); reconstruct_private_table(); db_multi_exec( "REPLACE INTO config(name,value,mtime) VALUES('content-schema',%Q,now());" "REPLACE INTO config(name,value,mtime) VALUES('aux-schema',%Q,now());" "REPLACE INTO config(name,value,mtime) VALUES('rebuilt',%Q,now());", CONTENT_SCHEMA, AUX_SCHEMA_MAX, get_version() ); if( errCnt && !forceFlag ){ fossil_print( "%d errors. Rolling back changes. Use --force to force a commit.\n", errCnt ); db_end_transaction(1); |
︙ | ︙ |
Changes to src/schema.c.
︙ | ︙ | |||
42 43 44 45 46 47 48 | ** The content tables have a content version number which rarely ** changes. The aux tables have an arbitrary version number (typically ** a date) which can change frequently. When the content schema changes, ** we have to execute special procedures to update the schema. When ** the aux schema changes, all we need to do is rebuild the database. */ #define CONTENT_SCHEMA "2" | | > | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | ** The content tables have a content version number which rarely ** changes. The aux tables have an arbitrary version number (typically ** a date) which can change frequently. When the content schema changes, ** we have to execute special procedures to update the schema. When ** the aux schema changes, all we need to do is rebuild the database. */ #define CONTENT_SCHEMA "2" #define AUX_SCHEMA_MIN "2011-04-25 19:50" #define AUX_SCHEMA_MAX "2014-11-24 20:35" #endif /* INTERFACE */ /* ** The schema for a repository database. ** |
︙ | ︙ | |||
248 249 250 251 252 253 254 255 256 257 258 259 260 261 | @ -- Parent/child linkages between checkins @ -- @ CREATE TABLE plink( @ pid INTEGER REFERENCES blob, -- Parent manifest @ cid INTEGER REFERENCES blob, -- Child manifest @ isprim BOOLEAN, -- pid is the primary parent of cid @ mtime DATETIME, -- the date/time stamp on cid. Julian day. @ UNIQUE(pid, cid) @ ); @ CREATE INDEX plink_i2 ON plink(cid,pid); @ @ -- A "leaf" checkin is a checkin that has no children in the same @ -- branch. The set of all leaves is easily computed with a join, @ -- between the plink and tagxref tables, but it is a slower join for | > | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | @ -- Parent/child linkages between checkins @ -- @ CREATE TABLE plink( @ pid INTEGER REFERENCES blob, -- Parent manifest @ cid INTEGER REFERENCES blob, -- Child manifest @ isprim BOOLEAN, -- pid is the primary parent of cid @ mtime DATETIME, -- the date/time stamp on cid. Julian day. @ baseid INTEGER REFERENCES blob, -- Baseline if child is a delta manifest @ UNIQUE(pid, cid) @ ); @ CREATE INDEX plink_i2 ON plink(cid,pid); @ @ -- A "leaf" checkin is a checkin that has no children in the same @ -- branch. The set of all leaves is easily computed with a join, @ -- between the plink and tagxref tables, but it is a slower join for |
︙ | ︙ |