Fossil SCM

Change all calls to json_extract() into uses of the new ->> operator.

drh 2022-01-13 12:50 trunk
Commit 50d433e5b0b483a7b910f1c76fc252ae46b5f3ab18dff0ef2cb96077e5141b0a
+1 -1
--- auto.def
+++ auto.def
@@ -33,11 +33,11 @@
3333
}
3434
3535
# Update the minimum required SQLite version number here, and also
3636
# in src/main.c near the sqlite3_libversion_number() call. Take care
3737
# that both places agree!
38
-define MINIMUM_SQLITE_VERSION "3.37.0"
38
+define MINIMUM_SQLITE_VERSION "3.38.0"
3939
4040
# This is useful for people wanting Fossil to use an external SQLite library
4141
# to compare the one they have against the minimum required
4242
if {[opt-bool print-minimum-sqlite-version]} {
4343
puts [get-define MINIMUM_SQLITE_VERSION]
4444
--- auto.def
+++ auto.def
@@ -33,11 +33,11 @@
33 }
34
35 # Update the minimum required SQLite version number here, and also
36 # in src/main.c near the sqlite3_libversion_number() call. Take care
37 # that both places agree!
38 define MINIMUM_SQLITE_VERSION "3.37.0"
39
40 # This is useful for people wanting Fossil to use an external SQLite library
41 # to compare the one they have against the minimum required
42 if {[opt-bool print-minimum-sqlite-version]} {
43 puts [get-define MINIMUM_SQLITE_VERSION]
44
--- auto.def
+++ auto.def
@@ -33,11 +33,11 @@
33 }
34
35 # Update the minimum required SQLite version number here, and also
36 # in src/main.c near the sqlite3_libversion_number() call. Take care
37 # that both places agree!
38 define MINIMUM_SQLITE_VERSION "3.38.0"
39
40 # This is useful for people wanting Fossil to use an external SQLite library
41 # to compare the one they have against the minimum required
42 if {[opt-bool print-minimum-sqlite-version]} {
43 puts [get-define MINIMUM_SQLITE_VERSION]
44
+11 -13
--- src/hook.c
+++ src/hook.c
@@ -355,13 +355,13 @@
355355
Stmt q;
356356
int n = 0;
357357
verify_all_options();
358358
db_prepare(&q,
359359
"SELECT jx.key,"
360
- " json_extract(jx.value,'$.seq'),"
361
- " json_extract(jx.value,'$.cmd'),"
362
- " json_extract(jx.value,'$.type')"
360
+ " jx.value->>'seq',"
361
+ " jx.value->>'cmd',"
362
+ " jx.value->>'type'"
363363
" FROM config, json_each(config.value) AS jx"
364364
" WHERE config.name='hooks' AND json_valid(config.value)"
365365
);
366366
while( db_step(&q)==SQLITE_ROW ){
367367
if( n++ ) fossil_print("\n");
@@ -395,12 +395,11 @@
395395
id = atoi(g.argv[3]);
396396
if( zOrigRcvid==0 ){
397397
zOrigRcvid = db_text(0, "SELECT max(rcvid)-1 FROM rcvfrom");
398398
}
399399
db_prepare(&q,
400
- "SELECT json_extract(value,'$[%d].cmd'), "
401
- " json_extract(value,'$[%d].type')=='after-receive'"
400
+ "SELECT value->>'$[%d].cmd', value->>'$[%d].type'=='after-receive'"
402401
" FROM config"
403402
" WHERE name='hooks' AND json_valid(value)",
404403
id, id
405404
);
406405
while( db_step(&q)==SQLITE_ROW ){
@@ -462,15 +461,15 @@
462461
if( atoi(zLastRcvid)>=atoi(zNewRcvid) ){
463462
goto hook_backoffice_done; /* no new content */
464463
}
465464
blob_init(&chng, 0, 0);
466465
db_prepare(&q,
467
- "SELECT json_extract(jx.value,'$.cmd') "
466
+ "SELECT jx.value->>'cmd'"
468467
" FROM config, json_each(config.value) AS jx"
469468
" WHERE config.name='hooks' AND json_valid(config.value)"
470
- " AND json_extract(jx.value,'$.type')='after-receive'"
471
- " ORDER BY json_extract(jx.value,'$.seq');"
469
+ " AND jx.value->>'type'='after-receive'"
470
+ " ORDER BY jx.value->>'seq';"
472471
);
473472
while( db_step(&q)==SQLITE_ROW ){
474473
char *zCmd;
475474
int fdFromChild;
476475
FILE *toChild;
@@ -502,12 +501,11 @@
502501
int hook_exists(const char *zType){
503502
return db_exists(
504503
"SELECT 1"
505504
" FROM config, json_each(config.value) AS jx"
506505
" WHERE config.name='hooks' AND json_valid(config.value)"
507
- " AND json_extract(jx.value,'$.type')=%Q"
508
- " ORDER BY json_extract(jx.value,'$.seq');",
506
+ " AND jx.value->>'type'=%Q;",
509507
zType
510508
);
511509
}
512510
513511
/*
@@ -522,15 +520,15 @@
522520
int rc = 0;
523521
if( !db_exists("SELECT 1 FROM config WHERE name='hooks'") ){
524522
return 0;
525523
}
526524
db_prepare(&q,
527
- "SELECT json_extract(jx.value,'$.cmd') "
525
+ "SELECT jx.value->>'cmd' "
528526
" FROM config, json_each(config.value) AS jx"
529527
" WHERE config.name='hooks' AND json_valid(config.value)"
530
- " AND json_extract(jx.value,'$.type')=%Q"
531
- " ORDER BY json_extract(jx.value,'$.seq');",
528
+ " AND jx.value->>'type'==%Q"
529
+ " ORDER BY jx.value->'seq';",
532530
zType
533531
);
534532
while( db_step(&q)==SQLITE_ROW ){
535533
char *zCmd;
536534
zCmd = hook_subst(db_column_text(&q,0), zAuxFile);
537535
--- src/hook.c
+++ src/hook.c
@@ -355,13 +355,13 @@
355 Stmt q;
356 int n = 0;
357 verify_all_options();
358 db_prepare(&q,
359 "SELECT jx.key,"
360 " json_extract(jx.value,'$.seq'),"
361 " json_extract(jx.value,'$.cmd'),"
362 " json_extract(jx.value,'$.type')"
363 " FROM config, json_each(config.value) AS jx"
364 " WHERE config.name='hooks' AND json_valid(config.value)"
365 );
366 while( db_step(&q)==SQLITE_ROW ){
367 if( n++ ) fossil_print("\n");
@@ -395,12 +395,11 @@
395 id = atoi(g.argv[3]);
396 if( zOrigRcvid==0 ){
397 zOrigRcvid = db_text(0, "SELECT max(rcvid)-1 FROM rcvfrom");
398 }
399 db_prepare(&q,
400 "SELECT json_extract(value,'$[%d].cmd'), "
401 " json_extract(value,'$[%d].type')=='after-receive'"
402 " FROM config"
403 " WHERE name='hooks' AND json_valid(value)",
404 id, id
405 );
406 while( db_step(&q)==SQLITE_ROW ){
@@ -462,15 +461,15 @@
462 if( atoi(zLastRcvid)>=atoi(zNewRcvid) ){
463 goto hook_backoffice_done; /* no new content */
464 }
465 blob_init(&chng, 0, 0);
466 db_prepare(&q,
467 "SELECT json_extract(jx.value,'$.cmd') "
468 " FROM config, json_each(config.value) AS jx"
469 " WHERE config.name='hooks' AND json_valid(config.value)"
470 " AND json_extract(jx.value,'$.type')='after-receive'"
471 " ORDER BY json_extract(jx.value,'$.seq');"
472 );
473 while( db_step(&q)==SQLITE_ROW ){
474 char *zCmd;
475 int fdFromChild;
476 FILE *toChild;
@@ -502,12 +501,11 @@
502 int hook_exists(const char *zType){
503 return db_exists(
504 "SELECT 1"
505 " FROM config, json_each(config.value) AS jx"
506 " WHERE config.name='hooks' AND json_valid(config.value)"
507 " AND json_extract(jx.value,'$.type')=%Q"
508 " ORDER BY json_extract(jx.value,'$.seq');",
509 zType
510 );
511 }
512
513 /*
@@ -522,15 +520,15 @@
522 int rc = 0;
523 if( !db_exists("SELECT 1 FROM config WHERE name='hooks'") ){
524 return 0;
525 }
526 db_prepare(&q,
527 "SELECT json_extract(jx.value,'$.cmd') "
528 " FROM config, json_each(config.value) AS jx"
529 " WHERE config.name='hooks' AND json_valid(config.value)"
530 " AND json_extract(jx.value,'$.type')=%Q"
531 " ORDER BY json_extract(jx.value,'$.seq');",
532 zType
533 );
534 while( db_step(&q)==SQLITE_ROW ){
535 char *zCmd;
536 zCmd = hook_subst(db_column_text(&q,0), zAuxFile);
537
--- src/hook.c
+++ src/hook.c
@@ -355,13 +355,13 @@
355 Stmt q;
356 int n = 0;
357 verify_all_options();
358 db_prepare(&q,
359 "SELECT jx.key,"
360 " jx.value->>'seq',"
361 " jx.value->>'cmd',"
362 " jx.value->>'type'"
363 " FROM config, json_each(config.value) AS jx"
364 " WHERE config.name='hooks' AND json_valid(config.value)"
365 );
366 while( db_step(&q)==SQLITE_ROW ){
367 if( n++ ) fossil_print("\n");
@@ -395,12 +395,11 @@
395 id = atoi(g.argv[3]);
396 if( zOrigRcvid==0 ){
397 zOrigRcvid = db_text(0, "SELECT max(rcvid)-1 FROM rcvfrom");
398 }
399 db_prepare(&q,
400 "SELECT value->>'$[%d].cmd', value->>'$[%d].type'=='after-receive'"
 
401 " FROM config"
402 " WHERE name='hooks' AND json_valid(value)",
403 id, id
404 );
405 while( db_step(&q)==SQLITE_ROW ){
@@ -462,15 +461,15 @@
461 if( atoi(zLastRcvid)>=atoi(zNewRcvid) ){
462 goto hook_backoffice_done; /* no new content */
463 }
464 blob_init(&chng, 0, 0);
465 db_prepare(&q,
466 "SELECT jx.value->>'cmd'"
467 " FROM config, json_each(config.value) AS jx"
468 " WHERE config.name='hooks' AND json_valid(config.value)"
469 " AND jx.value->>'type'='after-receive'"
470 " ORDER BY jx.value->>'seq';"
471 );
472 while( db_step(&q)==SQLITE_ROW ){
473 char *zCmd;
474 int fdFromChild;
475 FILE *toChild;
@@ -502,12 +501,11 @@
501 int hook_exists(const char *zType){
502 return db_exists(
503 "SELECT 1"
504 " FROM config, json_each(config.value) AS jx"
505 " WHERE config.name='hooks' AND json_valid(config.value)"
506 " AND jx.value->>'type'=%Q;",
 
507 zType
508 );
509 }
510
511 /*
@@ -522,15 +520,15 @@
520 int rc = 0;
521 if( !db_exists("SELECT 1 FROM config WHERE name='hooks'") ){
522 return 0;
523 }
524 db_prepare(&q,
525 "SELECT jx.value->>'cmd' "
526 " FROM config, json_each(config.value) AS jx"
527 " WHERE config.name='hooks' AND json_valid(config.value)"
528 " AND jx.value->>'type'==%Q"
529 " ORDER BY jx.value->'seq';",
530 zType
531 );
532 while( db_step(&q)==SQLITE_ROW ){
533 char *zCmd;
534 zCmd = hook_subst(db_column_text(&q,0), zAuxFile);
535
+8 -14
--- src/interwiki.c
+++ src/interwiki.c
@@ -83,14 +83,12 @@
8383
nCode = i;
8484
if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0;
8585
zPage = zTarget + nCode + 1;
8686
nPage = (int)strlen(zPage);
8787
db_static_prepare(&q,
88
- "SELECT json_extract(value,'$.base'),"
89
- " json_extract(value,'$.hash'),"
90
- " json_extract(value,'$.wiki')"
91
- " FROM config WHERE name=lower($name)"
88
+ "SELECT value->>'base', value->>'hash', value->>'wiki'"
89
+ " FROM config WHERE name=lower($name) AND json_valid(value)"
9290
);
9391
zName = mprintf("interwiki:%.*s", nCode, zTarget);
9492
db_bind_text(&q, "$name", zName);
9593
while( db_step(&q)==SQLITE_ROW ){
9694
const char *zBase = db_column_text(&q,0);
@@ -238,14 +236,12 @@
238236
Stmt q;
239237
int n = 0;
240238
verify_all_options();
241239
db_prepare(&q,
242240
"SELECT substr(name,11),"
243
- " json_extract(value,'$.base'),"
244
- " json_extract(value,'$.hash'),"
245
- " json_extract(value,'$.wiki')"
246
- " FROM config WHERE name glob 'interwiki:*'"
241
+ " value->>'base', value->>'hash', value->>'wiki'"
242
+ " FROM config WHERE name glob 'interwiki:*' AND json_valid(value)"
247243
);
248244
while( db_step(&q)==SQLITE_ROW ){
249245
const char *zBase, *z, *zName;
250246
if( n++ ) fossil_print("\n");
251247
zName = db_column_text(&q,0);
@@ -275,12 +271,12 @@
275271
*/
276272
void interwiki_append_map_table(Blob *out){
277273
int n = 0;
278274
Stmt q;
279275
db_prepare(&q,
280
- "SELECT substr(name,11), json_extract(value,'$.base')"
281
- " FROM config WHERE name glob 'interwiki:*'"
276
+ "SELECT substr(name,11), value->>'base'"
277
+ " FROM config WHERE name glob 'interwiki:*' AND json_valid(value)"
282278
" ORDER BY name;"
283279
);
284280
while( db_step(&q)==SQLITE_ROW ){
285281
if( n==0 ){
286282
blob_appendf(out, "<blockquote><table>\n");
@@ -352,14 +348,12 @@
352348
@ <p>Such links resolve to links to <i>PageName</i> on a separate server
353349
@ identified by <i>Tag</i>. The Interwiki Map or "intermap" is a mapping
354350
@ from <i>Tags</i> to complete Server URLs.
355351
db_prepare(&q,
356352
"SELECT substr(name,11),"
357
- " json_extract(value,'$.base'),"
358
- " json_extract(value,'$.hash'),"
359
- " json_extract(value,'$.wiki')"
360
- " FROM config WHERE name glob 'interwiki:*'"
353
+ " value->>'base', value->>'hash', value->>'wiki'"
354
+ " FROM config WHERE name glob 'interwiki:*' AND json_valid(value)"
361355
);
362356
while( db_step(&q)==SQLITE_ROW ){
363357
if( n==0 ){
364358
@ The current mapping is as follows:
365359
@ <ol>
366360
--- src/interwiki.c
+++ src/interwiki.c
@@ -83,14 +83,12 @@
83 nCode = i;
84 if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0;
85 zPage = zTarget + nCode + 1;
86 nPage = (int)strlen(zPage);
87 db_static_prepare(&q,
88 "SELECT json_extract(value,'$.base'),"
89 " json_extract(value,'$.hash'),"
90 " json_extract(value,'$.wiki')"
91 " FROM config WHERE name=lower($name)"
92 );
93 zName = mprintf("interwiki:%.*s", nCode, zTarget);
94 db_bind_text(&q, "$name", zName);
95 while( db_step(&q)==SQLITE_ROW ){
96 const char *zBase = db_column_text(&q,0);
@@ -238,14 +236,12 @@
238 Stmt q;
239 int n = 0;
240 verify_all_options();
241 db_prepare(&q,
242 "SELECT substr(name,11),"
243 " json_extract(value,'$.base'),"
244 " json_extract(value,'$.hash'),"
245 " json_extract(value,'$.wiki')"
246 " FROM config WHERE name glob 'interwiki:*'"
247 );
248 while( db_step(&q)==SQLITE_ROW ){
249 const char *zBase, *z, *zName;
250 if( n++ ) fossil_print("\n");
251 zName = db_column_text(&q,0);
@@ -275,12 +271,12 @@
275 */
276 void interwiki_append_map_table(Blob *out){
277 int n = 0;
278 Stmt q;
279 db_prepare(&q,
280 "SELECT substr(name,11), json_extract(value,'$.base')"
281 " FROM config WHERE name glob 'interwiki:*'"
282 " ORDER BY name;"
283 );
284 while( db_step(&q)==SQLITE_ROW ){
285 if( n==0 ){
286 blob_appendf(out, "<blockquote><table>\n");
@@ -352,14 +348,12 @@
352 @ <p>Such links resolve to links to <i>PageName</i> on a separate server
353 @ identified by <i>Tag</i>. The Interwiki Map or "intermap" is a mapping
354 @ from <i>Tags</i> to complete Server URLs.
355 db_prepare(&q,
356 "SELECT substr(name,11),"
357 " json_extract(value,'$.base'),"
358 " json_extract(value,'$.hash'),"
359 " json_extract(value,'$.wiki')"
360 " FROM config WHERE name glob 'interwiki:*'"
361 );
362 while( db_step(&q)==SQLITE_ROW ){
363 if( n==0 ){
364 @ The current mapping is as follows:
365 @ <ol>
366
--- src/interwiki.c
+++ src/interwiki.c
@@ -83,14 +83,12 @@
83 nCode = i;
84 if( nCode==4 && strncmp(zTarget,"wiki",4)==0 ) return 0;
85 zPage = zTarget + nCode + 1;
86 nPage = (int)strlen(zPage);
87 db_static_prepare(&q,
88 "SELECT value->>'base', value->>'hash', value->>'wiki'"
89 " FROM config WHERE name=lower($name) AND json_valid(value)"
 
 
90 );
91 zName = mprintf("interwiki:%.*s", nCode, zTarget);
92 db_bind_text(&q, "$name", zName);
93 while( db_step(&q)==SQLITE_ROW ){
94 const char *zBase = db_column_text(&q,0);
@@ -238,14 +236,12 @@
236 Stmt q;
237 int n = 0;
238 verify_all_options();
239 db_prepare(&q,
240 "SELECT substr(name,11),"
241 " value->>'base', value->>'hash', value->>'wiki'"
242 " FROM config WHERE name glob 'interwiki:*' AND json_valid(value)"
 
 
243 );
244 while( db_step(&q)==SQLITE_ROW ){
245 const char *zBase, *z, *zName;
246 if( n++ ) fossil_print("\n");
247 zName = db_column_text(&q,0);
@@ -275,12 +271,12 @@
271 */
272 void interwiki_append_map_table(Blob *out){
273 int n = 0;
274 Stmt q;
275 db_prepare(&q,
276 "SELECT substr(name,11), value->>'base'"
277 " FROM config WHERE name glob 'interwiki:*' AND json_valid(value)"
278 " ORDER BY name;"
279 );
280 while( db_step(&q)==SQLITE_ROW ){
281 if( n==0 ){
282 blob_appendf(out, "<blockquote><table>\n");
@@ -352,14 +348,12 @@
348 @ <p>Such links resolve to links to <i>PageName</i> on a separate server
349 @ identified by <i>Tag</i>. The Interwiki Map or "intermap" is a mapping
350 @ from <i>Tags</i> to complete Server URLs.
351 db_prepare(&q,
352 "SELECT substr(name,11),"
353 " value->>'base', value->>'hash', value->>'wiki'"
354 " FROM config WHERE name glob 'interwiki:*' AND json_valid(value)"
 
 
355 );
356 while( db_step(&q)==SQLITE_ROW ){
357 if( n==0 ){
358 @ The current mapping is as follows:
359 @ <ol>
360
+4 -2
--- src/main.c
+++ src/main.c
@@ -697,12 +697,14 @@
697697
fossil_limit_memory(1);
698698
699699
/* When updating the minimum SQLite version, change the number here,
700700
** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take
701701
** care that both places agree! */
702
- if( sqlite3_libversion_number()<3037000 ){
703
- fossil_panic("Unsuitable SQLite version %s, must be at least 3.37.0",
702
+ if( sqlite3_libversion_number()<3038000
703
+ || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0
704
+ ){
705
+ fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0",
704706
sqlite3_libversion());
705707
}
706708
707709
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
708710
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
709711
--- src/main.c
+++ src/main.c
@@ -697,12 +697,14 @@
697 fossil_limit_memory(1);
698
699 /* When updating the minimum SQLite version, change the number here,
700 ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take
701 ** care that both places agree! */
702 if( sqlite3_libversion_number()<3037000 ){
703 fossil_panic("Unsuitable SQLite version %s, must be at least 3.37.0",
 
 
704 sqlite3_libversion());
705 }
706
707 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
708 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
709
--- src/main.c
+++ src/main.c
@@ -697,12 +697,14 @@
697 fossil_limit_memory(1);
698
699 /* When updating the minimum SQLite version, change the number here,
700 ** and also MINIMUM_SQLITE_VERSION value set in ../auto.def. Take
701 ** care that both places agree! */
702 if( sqlite3_libversion_number()<3038000
703 || strncmp(sqlite3_sourceid(),"2022-01-12",10)<0
704 ){
705 fossil_panic("Unsuitable SQLite version %s, must be at least 3.38.0",
706 sqlite3_libversion());
707 }
708
709 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
710 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
711
+2 -2
--- src/stat.c
+++ src/stat.c
@@ -609,12 +609,12 @@
609609
cnt = 0;
610610
db_prepare(&q,
611611
"SELECT"
612612
" substr(name,6),"
613613
" datetime(mtime,'unixepoch'),"
614
- " json_extract(value,'$.type'),"
615
- " json_extract(value,'$.src')\n"
614
+ " value->>'type',"
615
+ " value->>'src'\n"
616616
"FROM config\n"
617617
"WHERE name GLOB 'link:*'\n"
618618
"AND json_valid(value)\n"
619619
"ORDER BY 4, 2 DESC"
620620
);
621621
--- src/stat.c
+++ src/stat.c
@@ -609,12 +609,12 @@
609 cnt = 0;
610 db_prepare(&q,
611 "SELECT"
612 " substr(name,6),"
613 " datetime(mtime,'unixepoch'),"
614 " json_extract(value,'$.type'),"
615 " json_extract(value,'$.src')\n"
616 "FROM config\n"
617 "WHERE name GLOB 'link:*'\n"
618 "AND json_valid(value)\n"
619 "ORDER BY 4, 2 DESC"
620 );
621
--- src/stat.c
+++ src/stat.c
@@ -609,12 +609,12 @@
609 cnt = 0;
610 db_prepare(&q,
611 "SELECT"
612 " substr(name,6),"
613 " datetime(mtime,'unixepoch'),"
614 " value->>'type',"
615 " value->>'src'\n"
616 "FROM config\n"
617 "WHERE name GLOB 'link:*'\n"
618 "AND json_valid(value)\n"
619 "ORDER BY 4, 2 DESC"
620 );
621
+6 -4
--- src/xfer.c
+++ src/xfer.c
@@ -1667,16 +1667,18 @@
16671667
Stmt q;
16681668
sqlite3_int64 iNow = time(0);
16691669
sqlite3_int64 maxAge = db_get_int("lock-timeout",60);
16701670
int seenFault = 0;
16711671
db_prepare(&q,
1672
- "SELECT json_extract(value,'$.login'),"
1672
+ "SELECT value->>'login',"
16731673
" mtime,"
1674
- " json_extract(value,'$.clientid'),"
1674
+ " value->>'clientid',"
16751675
" (SELECT rid FROM blob WHERE uuid=substr(name,9)),"
16761676
" name"
1677
- " FROM config WHERE name GLOB 'ci-lock-*'"
1677
+ " FROM config"
1678
+ " WHERE name GLOB 'ci-lock-*'"
1679
+ " AND json_valid(value)"
16781680
);
16791681
while( db_step(&q)==SQLITE_ROW ){
16801682
int x = db_column_int(&q,3);
16811683
const char *zName = db_column_text(&q,4);
16821684
if( db_column_int64(&q,1)<=iNow-maxAge || !is_a_leaf(x) ){
@@ -1725,11 +1727,11 @@
17251727
){
17261728
db_unprotect(PROTECT_CONFIG);
17271729
db_multi_exec(
17281730
"DELETE FROM config"
17291731
" WHERE name GLOB 'ci-lock-*'"
1730
- " AND json_extract(value,'$.clientid')=%Q",
1732
+ " AND (NOT json_valid(value) OR value->>'clientid'==%Q)",
17311733
blob_str(&xfer.aToken[2])
17321734
);
17331735
db_protect_pop();
17341736
}else
17351737
17361738
--- src/xfer.c
+++ src/xfer.c
@@ -1667,16 +1667,18 @@
1667 Stmt q;
1668 sqlite3_int64 iNow = time(0);
1669 sqlite3_int64 maxAge = db_get_int("lock-timeout",60);
1670 int seenFault = 0;
1671 db_prepare(&q,
1672 "SELECT json_extract(value,'$.login'),"
1673 " mtime,"
1674 " json_extract(value,'$.clientid'),"
1675 " (SELECT rid FROM blob WHERE uuid=substr(name,9)),"
1676 " name"
1677 " FROM config WHERE name GLOB 'ci-lock-*'"
 
 
1678 );
1679 while( db_step(&q)==SQLITE_ROW ){
1680 int x = db_column_int(&q,3);
1681 const char *zName = db_column_text(&q,4);
1682 if( db_column_int64(&q,1)<=iNow-maxAge || !is_a_leaf(x) ){
@@ -1725,11 +1727,11 @@
1725 ){
1726 db_unprotect(PROTECT_CONFIG);
1727 db_multi_exec(
1728 "DELETE FROM config"
1729 " WHERE name GLOB 'ci-lock-*'"
1730 " AND json_extract(value,'$.clientid')=%Q",
1731 blob_str(&xfer.aToken[2])
1732 );
1733 db_protect_pop();
1734 }else
1735
1736
--- src/xfer.c
+++ src/xfer.c
@@ -1667,16 +1667,18 @@
1667 Stmt q;
1668 sqlite3_int64 iNow = time(0);
1669 sqlite3_int64 maxAge = db_get_int("lock-timeout",60);
1670 int seenFault = 0;
1671 db_prepare(&q,
1672 "SELECT value->>'login',"
1673 " mtime,"
1674 " value->>'clientid',"
1675 " (SELECT rid FROM blob WHERE uuid=substr(name,9)),"
1676 " name"
1677 " FROM config"
1678 " WHERE name GLOB 'ci-lock-*'"
1679 " AND json_valid(value)"
1680 );
1681 while( db_step(&q)==SQLITE_ROW ){
1682 int x = db_column_int(&q,3);
1683 const char *zName = db_column_text(&q,4);
1684 if( db_column_int64(&q,1)<=iNow-maxAge || !is_a_leaf(x) ){
@@ -1725,11 +1727,11 @@
1727 ){
1728 db_unprotect(PROTECT_CONFIG);
1729 db_multi_exec(
1730 "DELETE FROM config"
1731 " WHERE name GLOB 'ci-lock-*'"
1732 " AND (NOT json_valid(value) OR value->>'clientid'==%Q)",
1733 blob_str(&xfer.aToken[2])
1734 );
1735 db_protect_pop();
1736 }else
1737
1738

Keyboard Shortcuts

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