Fossil SCM

Update "fossil rebuild" so that it changes the CHECK constraint on the BLOB table to be "length(uuid)>=40" instead of "==40".

drh 2017-02-28 02:10 fossil-2.0
Commit 2cce7d19d69378ef5c42cc576ffed5428f002a24
2 files changed +25 +1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -95,10 +95,11 @@
9595
/*
9696
** Update the schema as necessary
9797
*/
9898
static void rebuild_update_schema(void){
9999
int rc;
100
+ char *z;
100101
db_multi_exec("%s", zSchemaUpdates1 /*safe-for-%s*/);
101102
db_multi_exec("%s", zSchemaUpdates2 /*safe-for-%s*/);
102103
103104
/* Add the user.mtime column if it is missing.
104105
*/
@@ -172,10 +173,34 @@
172173
173174
/* If the alias table is missing, create it. */
174175
if( !db_table_exists("repository", "alias") ){
175176
db_multi_exec("%s", zSchemaUpdate3/*safe-for-%s*/);
176177
}
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
+
177202
}
178203
179204
/*
180205
** Variables used to store state information about an on-going "rebuild"
181206
** or "deconstruct".
182207
--- 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 @@
8181
@ rid INTEGER PRIMARY KEY, -- Record ID
8282
@ rcvid INTEGER, -- Origin of this record
8383
@ size INTEGER, -- Size of content. -1 for a phantom.
8484
@ uuid TEXT UNIQUE NOT NULL, -- hash of the content
8585
@ content BLOB, -- Compressed content of this record
86
-@ CHECK( length(uuid)==40 AND rid>0 )
86
+@ CHECK( length(uuid)>=40 AND rid>0 )
8787
@ );
8888
@ CREATE TABLE delta(
8989
@ rid INTEGER PRIMARY KEY, -- BLOB that is delta-compressed
9090
@ srcid INTEGER NOT NULL REFERENCES blob -- Baseline for delta-compression
9191
@ );
9292
--- 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

Keyboard Shortcuts

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