108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
-
+
-
+
+
+
+
+
|
** Return as follows:
** 0 Name is not a tag
** 1 A single UUID was found
** 2 More than one UUID was found, so this is presumably a
** propagating tag. The return UUID is the most recent,
** which is most likely to be the one wanted.
*/
int sym_tag_to_uuid(const char *pName, Blob *pUuid){
int tag_to_uuid(const char *pName, Blob *pUuid,const char *pPrefix){
Stmt q;
int count = 0;
db_prepare(&q,
"SELECT (SELECT uuid FROM blob WHERE rid=objid)"
" FROM tagxref JOIN event ON rid=objid"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname='sym-'||%Q)"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q||%Q)"
" AND tagtype>0"
" AND value IS NULL"
" ORDER BY event.mtime DESC",
pPrefix,
pName
);
blob_zero(pUuid);
while( db_step(&q)==SQLITE_ROW ){
count++;
if(count>1){
break;
}
db_column_blob(&q, 0, pUuid);
}
db_finalize(&q);
return count;
}
int sym_tag_to_uuid(const char *pName, Blob *pUuid){
return tag_to_uuid(pName,pUuid,"sym-");
}
/*
** COMMAND: test-name-to-uuid
**
** Convert a name to a full UUID.
*/
|