Fossil SCM
Update "fossil rebuild" so that it changes the CHECK constraint on the BLOB table to be "length(uuid)>=40" instead of "==40".
Commit
2cce7d19d69378ef5c42cc576ffed5428f002a24
Parent
65c597119c22519…
2 files changed
+25
+1
-1
+25
| --- src/rebuild.c | ||
| +++ src/rebuild.c | ||
| @@ -95,10 +95,11 @@ | ||
| 95 | 95 | /* |
| 96 | 96 | ** Update the schema as necessary |
| 97 | 97 | */ |
| 98 | 98 | static void rebuild_update_schema(void){ |
| 99 | 99 | int rc; |
| 100 | + char *z; | |
| 100 | 101 | db_multi_exec("%s", zSchemaUpdates1 /*safe-for-%s*/); |
| 101 | 102 | db_multi_exec("%s", zSchemaUpdates2 /*safe-for-%s*/); |
| 102 | 103 | |
| 103 | 104 | /* Add the user.mtime column if it is missing. |
| 104 | 105 | */ |
| @@ -172,10 +173,34 @@ | ||
| 172 | 173 | |
| 173 | 174 | /* If the alias table is missing, create it. */ |
| 174 | 175 | if( !db_table_exists("repository", "alias") ){ |
| 175 | 176 | db_multi_exec("%s", zSchemaUpdate3/*safe-for-%s*/); |
| 176 | 177 | } |
| 178 | + | |
| 179 | + /* Make sure the CHECK constraint on the BLOB table says "length(uuid)>=40" | |
| 180 | + ** instead of "length(uuid)==40". */ | |
| 181 | + z = db_text(0, "SELECT sql FROM repository.sqlite_master WHERE" | |
| 182 | + " name LIKE 'blob' AND sql LIKE '%%length(uuid)==40%%'"); | |
| 183 | + if( z ){ | |
| 184 | + /* Search for: length(uuid)==40 | |
| 185 | + ** 0123456789 12345 */ | |
| 186 | + int i; | |
| 187 | + for(i=10; z[i]; i++){ | |
| 188 | + if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){ | |
| 189 | + z[i] = '>'; | |
| 190 | + db_multi_exec( | |
| 191 | + "PRAGMA writable_schema=ON;" | |
| 192 | + "UPDATE repository.sqlite_master SET sql=%Q WHERE name LIKE 'blob';" | |
| 193 | + "PRAGMA writable_schema=OFF;", | |
| 194 | + z | |
| 195 | + ); | |
| 196 | + break; | |
| 197 | + } | |
| 198 | + } | |
| 199 | + fossil_free(z); | |
| 200 | + } | |
| 201 | + | |
| 177 | 202 | } |
| 178 | 203 | |
| 179 | 204 | /* |
| 180 | 205 | ** Variables used to store state information about an on-going "rebuild" |
| 181 | 206 | ** or "deconstruct". |
| 182 | 207 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -95,10 +95,11 @@ | |
| 95 | /* |
| 96 | ** Update the schema as necessary |
| 97 | */ |
| 98 | static void rebuild_update_schema(void){ |
| 99 | int rc; |
| 100 | db_multi_exec("%s", zSchemaUpdates1 /*safe-for-%s*/); |
| 101 | db_multi_exec("%s", zSchemaUpdates2 /*safe-for-%s*/); |
| 102 | |
| 103 | /* Add the user.mtime column if it is missing. |
| 104 | */ |
| @@ -172,10 +173,34 @@ | |
| 172 | |
| 173 | /* If the alias table is missing, create it. */ |
| 174 | if( !db_table_exists("repository", "alias") ){ |
| 175 | db_multi_exec("%s", zSchemaUpdate3/*safe-for-%s*/); |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | /* |
| 180 | ** Variables used to store state information about an on-going "rebuild" |
| 181 | ** or "deconstruct". |
| 182 |
| --- src/rebuild.c | |
| +++ src/rebuild.c | |
| @@ -95,10 +95,11 @@ | |
| 95 | /* |
| 96 | ** Update the schema as necessary |
| 97 | */ |
| 98 | static void rebuild_update_schema(void){ |
| 99 | int rc; |
| 100 | char *z; |
| 101 | db_multi_exec("%s", zSchemaUpdates1 /*safe-for-%s*/); |
| 102 | db_multi_exec("%s", zSchemaUpdates2 /*safe-for-%s*/); |
| 103 | |
| 104 | /* Add the user.mtime column if it is missing. |
| 105 | */ |
| @@ -172,10 +173,34 @@ | |
| 173 | |
| 174 | /* If the alias table is missing, create it. */ |
| 175 | if( !db_table_exists("repository", "alias") ){ |
| 176 | db_multi_exec("%s", zSchemaUpdate3/*safe-for-%s*/); |
| 177 | } |
| 178 | |
| 179 | /* Make sure the CHECK constraint on the BLOB table says "length(uuid)>=40" |
| 180 | ** instead of "length(uuid)==40". */ |
| 181 | z = db_text(0, "SELECT sql FROM repository.sqlite_master WHERE" |
| 182 | " name LIKE 'blob' AND sql LIKE '%%length(uuid)==40%%'"); |
| 183 | if( z ){ |
| 184 | /* Search for: length(uuid)==40 |
| 185 | ** 0123456789 12345 */ |
| 186 | int i; |
| 187 | for(i=10; z[i]; i++){ |
| 188 | if( z[i]=='=' && strncmp(&z[i-6],"(uuid)==40",10)==0 ){ |
| 189 | z[i] = '>'; |
| 190 | db_multi_exec( |
| 191 | "PRAGMA writable_schema=ON;" |
| 192 | "UPDATE repository.sqlite_master SET sql=%Q WHERE name LIKE 'blob';" |
| 193 | "PRAGMA writable_schema=OFF;", |
| 194 | z |
| 195 | ); |
| 196 | break; |
| 197 | } |
| 198 | } |
| 199 | fossil_free(z); |
| 200 | } |
| 201 | |
| 202 | } |
| 203 | |
| 204 | /* |
| 205 | ** Variables used to store state information about an on-going "rebuild" |
| 206 | ** or "deconstruct". |
| 207 |
+1
-1
| --- src/schema.c | ||
| +++ src/schema.c | ||
| @@ -81,11 +81,11 @@ | ||
| 81 | 81 | @ rid INTEGER PRIMARY KEY, -- Record ID |
| 82 | 82 | @ rcvid INTEGER, -- Origin of this record |
| 83 | 83 | @ size INTEGER, -- Size of content. -1 for a phantom. |
| 84 | 84 | @ uuid TEXT UNIQUE NOT NULL, -- hash of the content |
| 85 | 85 | @ content BLOB, -- Compressed content of this record |
| 86 | -@ CHECK( length(uuid)==40 AND rid>0 ) | |
| 86 | +@ CHECK( length(uuid)>=40 AND rid>0 ) | |
| 87 | 87 | @ ); |
| 88 | 88 | @ CREATE TABLE delta( |
| 89 | 89 | @ rid INTEGER PRIMARY KEY, -- BLOB that is delta-compressed |
| 90 | 90 | @ srcid INTEGER NOT NULL REFERENCES blob -- Baseline for delta-compression |
| 91 | 91 | @ ); |
| 92 | 92 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -81,11 +81,11 @@ | |
| 81 | @ rid INTEGER PRIMARY KEY, -- Record ID |
| 82 | @ rcvid INTEGER, -- Origin of this record |
| 83 | @ size INTEGER, -- Size of content. -1 for a phantom. |
| 84 | @ uuid TEXT UNIQUE NOT NULL, -- hash of the content |
| 85 | @ content BLOB, -- Compressed content of this record |
| 86 | @ CHECK( length(uuid)==40 AND rid>0 ) |
| 87 | @ ); |
| 88 | @ CREATE TABLE delta( |
| 89 | @ rid INTEGER PRIMARY KEY, -- BLOB that is delta-compressed |
| 90 | @ srcid INTEGER NOT NULL REFERENCES blob -- Baseline for delta-compression |
| 91 | @ ); |
| 92 |
| --- src/schema.c | |
| +++ src/schema.c | |
| @@ -81,11 +81,11 @@ | |
| 81 | @ rid INTEGER PRIMARY KEY, -- Record ID |
| 82 | @ rcvid INTEGER, -- Origin of this record |
| 83 | @ size INTEGER, -- Size of content. -1 for a phantom. |
| 84 | @ uuid TEXT UNIQUE NOT NULL, -- hash of the content |
| 85 | @ content BLOB, -- Compressed content of this record |
| 86 | @ CHECK( length(uuid)>=40 AND rid>0 ) |
| 87 | @ ); |
| 88 | @ CREATE TABLE delta( |
| 89 | @ rid INTEGER PRIMARY KEY, -- BLOB that is delta-compressed |
| 90 | @ srcid INTEGER NOT NULL REFERENCES blob -- Baseline for delta-compression |
| 91 | @ ); |
| 92 |