37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
** user input with mixed case, use resolve_uuid().
**
** If the UUID is not found and phantomize is 1, then attempt to
** create a phantom record.
*/
int uuid_to_rid(const char *zUuid, int phantomize){
int rid, sz;
char z[UUID_SIZE+1];
sz = strlen(zUuid);
if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){
return 0;
}
strcpy(z, zUuid);
canonical16(z, sz);
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", z);
if( rid==0 && phantomize ){
rid = content_put(0, zUuid, 0);
}
return rid;
}
/*
** Verify that an object is not a phantom. If the object is
** a phantom, output an error message and quick.
|
>
|
>
>
>
>
>
>
>
|
|
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
** user input with mixed case, use resolve_uuid().
**
** If the UUID is not found and phantomize is 1, then attempt to
** create a phantom record.
*/
int uuid_to_rid(const char *zUuid, int phantomize){
int rid, sz;
static Stmt q;
char z[UUID_SIZE+1];
sz = strlen(zUuid);
if( sz!=UUID_SIZE || !validate16(zUuid, sz) ){
return 0;
}
strcpy(z, zUuid);
canonical16(z, sz);
db_static_prepare(&q, "SELECT rid FROM blob WHERE uuid=:uuid");
db_bind_text(&q, ":uuid", z);
if( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
}else{
rid = 0;
}
db_reset(&q);
if( rid==0 && phantomize ){
rid = content_new(zUuid);
}
return rid;
}
/*
** Verify that an object is not a phantom. If the object is
** a phantom, output an error message and quick.
|