Fossil SCM
Fix the creation of orphan table entries when delta-manifests are received before their baselines. Ticket [fbea61caf0acfd0a].
Commit
195073fb78f7c6a112104b330fd50887bf54475c
Parent
81ad6e2e20955d5…
1 file changed
+4
-11
+4
-11
| --- src/manifest.c | ||
| +++ src/manifest.c | ||
| @@ -863,10 +863,11 @@ | ||
| 863 | 863 | ** a pointer to the manifest on success or NULL if there is a failure. |
| 864 | 864 | */ |
| 865 | 865 | Manifest *manifest_get(int rid, int cfType){ |
| 866 | 866 | Blob content; |
| 867 | 867 | Manifest *p; |
| 868 | + if( !rid ) return 0; | |
| 868 | 869 | p = manifest_cache_find(rid); |
| 869 | 870 | if( p ){ |
| 870 | 871 | if( cfType!=CFTYPE_ANY && cfType!=p->type ){ |
| 871 | 872 | manifest_cache_insert(p); |
| 872 | 873 | p = 0; |
| @@ -931,29 +932,21 @@ | ||
| 931 | 932 | /* |
| 932 | 933 | ** Fetch the baseline associated with the delta-manifest p. |
| 933 | 934 | ** Return 0 on success. If unable to parse the baseline, |
| 934 | 935 | ** throw an error. If the baseline is a manifest, throw an |
| 935 | 936 | ** error if throwError is true, or record that p is an orphan |
| 936 | -** and return 1 throwError is false. | |
| 937 | +** and return 1 if throwError is false. | |
| 937 | 938 | */ |
| 938 | 939 | static int fetch_baseline(Manifest *p, int throwError){ |
| 939 | 940 | if( p->zBaseline!=0 && p->pBaseline==0 ){ |
| 940 | - int rid = uuid_to_rid(p->zBaseline, 0); | |
| 941 | - if( rid==0 && !throwError ){ | |
| 942 | - rid = content_new(p->zBaseline); | |
| 943 | - db_multi_exec( | |
| 944 | - "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", | |
| 945 | - rid, p->rid | |
| 946 | - ); | |
| 947 | - return 1; | |
| 948 | - } | |
| 941 | + int rid = uuid_to_rid(p->zBaseline, 1); | |
| 949 | 942 | p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST); |
| 950 | 943 | if( p->pBaseline==0 ){ |
| 951 | 944 | if( !throwError ){ |
| 952 | 945 | db_multi_exec( |
| 953 | 946 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 954 | - rid, p->rid | |
| 947 | + p->rid, rid | |
| 955 | 948 | ); |
| 956 | 949 | return 1; |
| 957 | 950 | } |
| 958 | 951 | fossil_fatal("cannot access baseline manifest %S", p->zBaseline); |
| 959 | 952 | } |
| 960 | 953 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -863,10 +863,11 @@ | |
| 863 | ** a pointer to the manifest on success or NULL if there is a failure. |
| 864 | */ |
| 865 | Manifest *manifest_get(int rid, int cfType){ |
| 866 | Blob content; |
| 867 | Manifest *p; |
| 868 | p = manifest_cache_find(rid); |
| 869 | if( p ){ |
| 870 | if( cfType!=CFTYPE_ANY && cfType!=p->type ){ |
| 871 | manifest_cache_insert(p); |
| 872 | p = 0; |
| @@ -931,29 +932,21 @@ | |
| 931 | /* |
| 932 | ** Fetch the baseline associated with the delta-manifest p. |
| 933 | ** Return 0 on success. If unable to parse the baseline, |
| 934 | ** throw an error. If the baseline is a manifest, throw an |
| 935 | ** error if throwError is true, or record that p is an orphan |
| 936 | ** and return 1 throwError is false. |
| 937 | */ |
| 938 | static int fetch_baseline(Manifest *p, int throwError){ |
| 939 | if( p->zBaseline!=0 && p->pBaseline==0 ){ |
| 940 | int rid = uuid_to_rid(p->zBaseline, 0); |
| 941 | if( rid==0 && !throwError ){ |
| 942 | rid = content_new(p->zBaseline); |
| 943 | db_multi_exec( |
| 944 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 945 | rid, p->rid |
| 946 | ); |
| 947 | return 1; |
| 948 | } |
| 949 | p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST); |
| 950 | if( p->pBaseline==0 ){ |
| 951 | if( !throwError ){ |
| 952 | db_multi_exec( |
| 953 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 954 | rid, p->rid |
| 955 | ); |
| 956 | return 1; |
| 957 | } |
| 958 | fossil_fatal("cannot access baseline manifest %S", p->zBaseline); |
| 959 | } |
| 960 |
| --- src/manifest.c | |
| +++ src/manifest.c | |
| @@ -863,10 +863,11 @@ | |
| 863 | ** a pointer to the manifest on success or NULL if there is a failure. |
| 864 | */ |
| 865 | Manifest *manifest_get(int rid, int cfType){ |
| 866 | Blob content; |
| 867 | Manifest *p; |
| 868 | if( !rid ) return 0; |
| 869 | p = manifest_cache_find(rid); |
| 870 | if( p ){ |
| 871 | if( cfType!=CFTYPE_ANY && cfType!=p->type ){ |
| 872 | manifest_cache_insert(p); |
| 873 | p = 0; |
| @@ -931,29 +932,21 @@ | |
| 932 | /* |
| 933 | ** Fetch the baseline associated with the delta-manifest p. |
| 934 | ** Return 0 on success. If unable to parse the baseline, |
| 935 | ** throw an error. If the baseline is a manifest, throw an |
| 936 | ** error if throwError is true, or record that p is an orphan |
| 937 | ** and return 1 if throwError is false. |
| 938 | */ |
| 939 | static int fetch_baseline(Manifest *p, int throwError){ |
| 940 | if( p->zBaseline!=0 && p->pBaseline==0 ){ |
| 941 | int rid = uuid_to_rid(p->zBaseline, 1); |
| 942 | p->pBaseline = manifest_get(rid, CFTYPE_MANIFEST); |
| 943 | if( p->pBaseline==0 ){ |
| 944 | if( !throwError ){ |
| 945 | db_multi_exec( |
| 946 | "INSERT OR IGNORE INTO orphan(rid, baseline) VALUES(%d,%d)", |
| 947 | p->rid, rid |
| 948 | ); |
| 949 | return 1; |
| 950 | } |
| 951 | fossil_fatal("cannot access baseline manifest %S", p->zBaseline); |
| 952 | } |
| 953 |