71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
if( db_step(&q)==SQLITE_ROW ){
nNonBranch = db_column_int(&q, 0);
}
db_reset(&q);
return nNonBranch;
}
/*
** Return the primary parent pid given a child rid
*/
int primary_parent_pid_from_rid(int rid){
static Stmt q;
int pid = -1;
db_static_prepare(&q,
"SELECT pid FROM plink WHERE cid=:rid AND pid>0 AND isprim"
);
db_bind_int(&q, ":rid", rid);
if( db_step(&q)==SQLITE_ROW ){
pid = db_column_int(&q, 0);
}
db_reset(&q);
return pid;
}
/*
** Recompute the entire LEAF table.
**
** This can be expensive (5 seconds or so) for a really large repository.
** So it is only done for things like a rebuild.
*/
void leaf_rebuild(void){
|