Fossil

Diff
Login

Diff

Differences From Artifact [cf6d41165c]:

To Artifact [80c78efef9]:


274
275
276
277
278
279
280
281

282
283
284
285
286
287
288
274
275
276
277
278
279
280

281
282
283
284
285
286
287
288







-
+







  va_list ap;
  va_start(ap, zFormat);
  rc = db_vprepare(pStmt, 1, zFormat, ap);
  va_end(ap);
  return rc;
}
int db_static_prepare(Stmt *pStmt, const char *zFormat, ...){
  int rc = SQLITE_OK;
  int rc = SQLITE4_OK;
  if( blob_size(&pStmt->sql)==0 ){
    va_list ap;
    va_start(ap, zFormat);
    rc = db_vprepare(pStmt, 0, zFormat, ap);
    pStmt->pNext = db.pAllStmt;
    pStmt->pPrev = 0;
    if( db.pAllStmt ) db.pAllStmt->pPrev = pStmt;
312
313
314
315
316
317
318
319

320
321
322
323
324
325
326

327
328
329
330
331
332
333
334
335

336
337
338
339
340


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359



360
361
362
363
364
365
366
312
313
314
315
316
317
318

319
320
321
322
323
324
325

326
327
328
329
330
331
332
333
334

335
336
337
338


339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356



357
358
359
360
361
362
363
364
365
366







-
+






-
+








-
+



-
-
+
+
















-
-
-
+
+
+







  return sqlite4_bind_int64(pStmt->pStmt, paramIdx(pStmt, zParamName), iValue);
}
int db_bind_double(Stmt *pStmt, const char *zParamName, double rValue){
  return sqlite4_bind_double(pStmt->pStmt, paramIdx(pStmt, zParamName), rValue);
}
int db_bind_text(Stmt *pStmt, const char *zParamName, const char *zValue){
  return sqlite4_bind_text(pStmt->pStmt, paramIdx(pStmt, zParamName), zValue,
                           -1, SQLITE_STATIC);
                           -1, SQLITE4_STATIC);
}
int db_bind_null(Stmt *pStmt, const char *zParamName){
  return sqlite4_bind_null(pStmt->pStmt, paramIdx(pStmt, zParamName));
}
int db_bind_blob(Stmt *pStmt, const char *zParamName, Blob *pBlob){
  return sqlite4_bind_blob(pStmt->pStmt, paramIdx(pStmt, zParamName),
                          blob_buffer(pBlob), blob_size(pBlob), SQLITE_STATIC);
                          blob_buffer(pBlob), blob_size(pBlob), SQLITE4_STATIC);
}

/* bind_str() treats a Blob object like a TEXT string and binds it
** to the SQL variable.  Constrast this to bind_blob() which treats
** the Blob object like an SQL BLOB.
*/
int db_bind_str(Stmt *pStmt, const char *zParamName, Blob *pBlob){
  return sqlite4_bind_text(pStmt->pStmt, paramIdx(pStmt, zParamName),
                          blob_buffer(pBlob), blob_size(pBlob), SQLITE_STATIC);
                          blob_buffer(pBlob), blob_size(pBlob), SQLITE4_STATIC);
}

/*
** Step the SQL statement.  Return either SQLITE_ROW or an error code
** or SQLITE_OK if the statement finishes successfully.
** Step the SQL statement.  Return either SQLITE4_ROW or an error code
** or SQLITE4_OK if the statement finishes successfully.
*/
int db_step(Stmt *pStmt){
  int rc;
  rc = sqlite4_step(pStmt->pStmt);
  pStmt->nStep++;
  return rc;
}

/*
** Print warnings if a query is inefficient.
*/
static void db_stats(Stmt *pStmt){
#ifdef FOSSIL_DEBUG
  int c1, c2, c3;
  const char *zSql = sqlite4_sql(pStmt->pStmt);
  if( zSql==0 ) return;
  c1 = sqlite4_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_FULLSCAN_STEP, 1);
  c2 = sqlite4_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_AUTOINDEX, 1);
  c3 = sqlite4_stmt_status(pStmt->pStmt, SQLITE_STMTSTATUS_SORT, 1);
  c1 = sqlite4_stmt_status(pStmt->pStmt, SQLITE4_STMTSTATUS_FULLSCAN_STEP, 1);
  c2 = sqlite4_stmt_status(pStmt->pStmt, SQLITE4_STMTSTATUS_AUTOINDEX, 1);
  c3 = sqlite4_stmt_status(pStmt->pStmt, SQLITE4_STMTSTATUS_SORT, 1);
  if( c1>pStmt->nStep*4 && strstr(zSql,"/*scan*/")==0 ){
    fossil_warning("%d scan steps for %d rows in [%s]", c1, pStmt->nStep, zSql);
  }else if( c2 ){
    fossil_warning("%d automatic index rows in [%s]", c2, zSql);
  }else if( c3 && strstr(zSql,"/*sort*/")==0 && strstr(zSql,"/*scan*/")==0 ){
    fossil_warning("sort w/o index in [%s]", zSql);
  }
457
458
459
460
461
462
463
464

465
466
467
468

469
470
471
472
473
474
475
476
477
478

479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497

498
499
500
501
502
503
504
457
458
459
460
461
462
463

464
465
466
467

468
469
470
471
472
473
474
475
476
477

478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496

497
498
499
500
501
502
503
504







-
+



-
+









-
+


















-
+







*/
void db_ephemeral_blob(Stmt *pStmt, int N, Blob *pBlob){
  blob_init(pBlob, sqlite4_column_blob(pStmt->pStmt, N),
              sqlite4_column_bytes(pStmt->pStmt, N));
}

/*
** Check a result code.  If it is not SQLITE_OK, print the
** Check a result code.  If it is not SQLITE4_OK, print the
** corresponding error message and exit.
*/
void db_check_result(int rc){
  if( rc!=SQLITE_OK ){
  if( rc!=SQLITE4_OK ){
    db_err("SQL error: %s", sqlite4_errmsg(g.db));
  }
}

/*
** Execute a single prepared statement until it finishes.
*/
int db_exec(Stmt *pStmt){
  int rc;
  while( (rc = db_step(pStmt))==SQLITE_ROW ){}
  while( (rc = db_step(pStmt))==SQLITE4_ROW ){}
  rc = db_reset(pStmt);
  db_check_result(rc);
  return rc;
}

/*
** Execute multiple SQL statements.
*/
int db_multi_exec(const char *zSql, ...){
  Blob sql;
  int rc;
  va_list ap;
  char *zErr = 0;
  blob_init(&sql, 0, 0);
  va_start(ap, zSql);
  blob_vappendf(&sql, zSql, ap);
  va_end(ap);
  rc = sqlite4_exec(g.db, blob_buffer(&sql), 0, 0, &zErr);
  if( rc!=SQLITE_OK ){
  if( rc!=SQLITE4_OK ){
    db_err("%s\n%s", zErr, blob_buffer(&sql));
  }
  blob_reset(&sql);
  return rc;
}

/*
521
522
523
524
525
526
527
528

529
530
531
532
533
534
535
536
537
538
539
540
541
542
543

544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563

564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583

584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602

603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622

623
624
625
626
627
628
629
521
522
523
524
525
526
527

528
529
530
531
532
533
534
535
536
537
538
539
540
541
542

543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562

563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582

583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601

602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621

622
623
624
625
626
627
628
629







-
+














-
+



















-
+



















-
+


















-
+



















-
+







i64 db_int64(i64 iDflt, const char *zSql, ...){
  va_list ap;
  Stmt s;
  i64 rc;
  va_start(ap, zSql);
  db_vprepare(&s, 0, zSql, ap);
  va_end(ap);
  if( db_step(&s)!=SQLITE_ROW ){
  if( db_step(&s)!=SQLITE4_ROW ){
    rc = iDflt;
  }else{
    rc = db_column_int64(&s, 0);
  }
  db_finalize(&s);
  return rc;
}
int db_int(int iDflt, const char *zSql, ...){
  va_list ap;
  Stmt s;
  int rc;
  va_start(ap, zSql);
  db_vprepare(&s, 0, zSql, ap);
  va_end(ap);
  if( db_step(&s)!=SQLITE_ROW ){
  if( db_step(&s)!=SQLITE4_ROW ){
    rc = iDflt;
  }else{
    rc = db_column_int(&s, 0);
  }
  db_finalize(&s);
  return rc;
}

/*
** Return TRUE if the query would return 1 or more rows.  Return
** FALSE if the query result would be an empty set.
*/
int db_exists(const char *zSql, ...){
  va_list ap;
  Stmt s;
  int rc;
  va_start(ap, zSql);
  db_vprepare(&s, 0, zSql, ap);
  va_end(ap);
  if( db_step(&s)!=SQLITE_ROW ){
  if( db_step(&s)!=SQLITE4_ROW ){
    rc = 0;
  }else{
    rc = 1;
  }
  db_finalize(&s);
  return rc;
}


/*
** Execute a query and return a floating-point value.
*/
double db_double(double rDflt, const char *zSql, ...){
  va_list ap;
  Stmt s;
  double r;
  va_start(ap, zSql);
  db_vprepare(&s, 0, zSql, ap);
  va_end(ap);
  if( db_step(&s)!=SQLITE_ROW ){
  if( db_step(&s)!=SQLITE4_ROW ){
    r = rDflt;
  }else{
    r = db_column_double(&s, 0);
  }
  db_finalize(&s);
  return r;
}

/*
** Execute a query and append the first column of the first row
** of the result set to blob given in the first argument.
*/
void db_blob(Blob *pResult, const char *zSql, ...){
  va_list ap;
  Stmt s;
  va_start(ap, zSql);
  db_vprepare(&s, 0, zSql, ap);
  va_end(ap);
  if( db_step(&s)==SQLITE_ROW ){
  if( db_step(&s)==SQLITE4_ROW ){
    blob_append(pResult, sqlite4_column_blob(s.pStmt, 0),
                         sqlite4_column_bytes(s.pStmt, 0));
  }
  db_finalize(&s);
}

/*
** Execute a query.  Return the first column of the first row
** of the result set as a string.  Space to hold the string is
** obtained from malloc().  If the result set is empty, return
** zDefault instead.
*/
char *db_text(char const *zDefault, const char *zSql, ...){
  va_list ap;
  Stmt s;
  char *z;
  va_start(ap, zSql);
  db_vprepare(&s, 0, zSql, ap);
  va_end(ap);
  if( db_step(&s)==SQLITE_ROW ){
  if( db_step(&s)==SQLITE4_ROW ){
    z = mprintf("%s", sqlite4_column_text(s.pStmt, 0));
  }else if( zDefault ){
    z = mprintf("%s", zDefault);
  }else{
    z = 0;
  }
  db_finalize(&s);
641
642
643
644
645
646
647
648
649


650
651
652
653
654

655
656
657
658
659
660

661
662
663
664
665
666
667
641
642
643
644
645
646
647


648
649
650
651
652
653

654
655
656
657
658
659

660
661
662
663
664
665
666
667







-
-
+
+




-
+





-
+







){
  sqlite4 *db;
  int rc;
  const char *zSql;
  va_list ap;

  rc = sqlite4_open(0, zFileName, &db,
                    SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
  if( rc!=SQLITE_OK ){
                    SQLITE4_OPEN_READWRITE|SQLITE4_OPEN_CREATE);
  if( rc!=SQLITE4_OK ){
    db_err(sqlite4_errmsg(db));
  }
  sqlite4_exec(db, "BEGIN EXCLUSIVE", 0, 0, 0);
  rc = sqlite4_exec(db, zSchema, 0, 0, 0);
  if( rc!=SQLITE_OK ){
  if( rc!=SQLITE4_OK ){
    db_err(sqlite4_errmsg(db));
  }
  va_start(ap, zSchema);
  while( (zSql = va_arg(ap, const char*))!=0 ){
    rc = sqlite4_exec(db, zSql, 0, 0, 0);
    if( rc!=SQLITE_OK ){
    if( rc!=SQLITE4_OK ){
      db_err(sqlite4_errmsg(db));
    }
  }
  va_end(ap);
  sqlite4_exec(db, "COMMIT", 0, 0, 0);
  sqlite4_close(db);
}
687
688
689
690
691
692
693
694

695
696

697
698
699

700
701
702
703
704
705
706
687
688
689
690
691
692
693

694
695

696
697
698

699
700
701
702
703
704
705
706







-
+

-
+


-
+







  int rc;
  const char *zVfs;
  sqlite4 *db;

  zVfs = fossil_getenv("FOSSIL_VFS");
  rc = sqlite4_open(0,
       zDbName, &db,
       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
       SQLITE4_OPEN_READWRITE | SQLITE4_OPEN_CREATE
  );
  if( rc!=SQLITE_OK ){
  if( rc!=SQLITE4_OK ){
    db_err(sqlite4_errmsg(db));
  }
  sqlite4_create_function(db, "now", 0, SQLITE_ANY, 0, db_now_function, 0, 0);
  sqlite4_create_function(db, "now", 0, SQLITE4_ANY, 0, db_now_function, 0, 0);
  return db;
}


/*
** zDbName is the name of a database file.  If no other database
** file is open, then open this one.  If another database file is
1095
1096
1097
1098
1099
1100
1101
1102

1103
1104

1105
1106

1107
1108

1109
1110

1111
1112

1113
1114

1115
1116

1117
1118

1119
1120

1121
1122
1123
1124
1125
1126
1127
1095
1096
1097
1098
1099
1100
1101

1102
1103

1104
1105

1106
1107

1108
1109

1110
1111

1112
1113

1114
1115

1116
1117

1118
1119

1120
1121
1122
1123
1124
1125
1126
1127







-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+

-
+







** argument is true.  Ignore unfinalized statements when false.
*/
void db_close(int reportErrors){
  sqlite4_stmt *pStmt;
  if( g.db==0 ) return;
  if( g.fSqlStats ){
    int cur, hiwtr;
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_LOOKASIDE_USED, &cur, &hiwtr, 0);
    fprintf(stderr, "-- LOOKASIDE_USED         %10d %10d\n", cur, hiwtr);
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &cur, &hiwtr, 0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_LOOKASIDE_HIT, &cur, &hiwtr, 0);
    fprintf(stderr, "-- LOOKASIDE_HIT                     %10d\n", hiwtr);
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &cur,&hiwtr,0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_LOOKASIDE_MISS_SIZE, &cur,&hiwtr,0);
    fprintf(stderr, "-- LOOKASIDE_MISS_SIZE               %10d\n", hiwtr);
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &cur,&hiwtr,0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_LOOKASIDE_MISS_FULL, &cur,&hiwtr,0);
    fprintf(stderr, "-- LOOKASIDE_MISS_FULL               %10d\n", hiwtr);
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_CACHE_USED, &cur, &hiwtr, 0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_CACHE_USED, &cur, &hiwtr, 0);
    fprintf(stderr, "-- CACHE_USED             %10d\n", cur);
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_SCHEMA_USED, &cur, &hiwtr, 0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_SCHEMA_USED, &cur, &hiwtr, 0);
    fprintf(stderr, "-- SCHEMA_USED            %10d\n", cur);
    sqlite4_db_status(g.db, SQLITE_DBSTATUS_STMT_USED, &cur, &hiwtr, 0);
    sqlite4_db_status(g.db, SQLITE4_DBSTATUS_STMT_USED, &cur, &hiwtr, 0);
    fprintf(stderr, "-- STMT_USED              %10d\n", cur);
    sqlite4_env_status(0, SQLITE_ENVSTATUS_MEMORY_USED, &cur, &hiwtr, 0);
    sqlite4_env_status(0, SQLITE4_ENVSTATUS_MEMORY_USED, &cur, &hiwtr, 0);
    fprintf(stderr, "-- MEMORY_USED            %10d %10d\n", cur, hiwtr);
    sqlite4_env_status(0, SQLITE_ENVSTATUS_MALLOC_SIZE, &cur, &hiwtr, 0);
    sqlite4_env_status(0, SQLITE4_ENVSTATUS_MALLOC_SIZE, &cur, &hiwtr, 0);
    fprintf(stderr, "-- MALLOC_SIZE                       %10d\n", hiwtr);
    sqlite4_env_status(0, SQLITE_ENVSTATUS_MALLOC_COUNT, &cur, &hiwtr, 0);
    sqlite4_env_status(0, SQLITE4_ENVSTATUS_MALLOC_COUNT, &cur, &hiwtr, 0);
    fprintf(stderr, "-- MALLOC_COUNT           %10d %10d\n", cur, hiwtr);
    fprintf(stderr, "-- prepared statements    %10d\n", db.nPrepare);
  }
  while( db.pAllStmt ){
    db_finalize(db.pAllStmt);
  }
  db_end_transaction(1);
1331
1332
1333
1334
1335
1336
1337
1338

1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353

1354
1355
1356

1357
1358
1359
1360
1361
1362
1363
1331
1332
1333
1334
1335
1336
1337

1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352

1353
1354
1355

1356
1357
1358
1359
1360
1361
1362
1363







-
+














-
+


-
+







*/
static void db_sql_user(
  sqlite4_context *context,
  int argc,
  sqlite4_value **argv
){
  if( g.zLogin!=0 ){
    sqlite4_result_text(context, g.zLogin, -1, SQLITE_STATIC);
    sqlite4_result_text(context, g.zLogin, -1, SQLITE4_STATIC);
  }
}

/*
** Implement the cgi() SQL function.  cgi() takes a an argument which is
** a name of CGI query parameter. The value of that parameter is returned, 
** if available. optional second argument will be returned if the first
** doesn't exist as a CGI parameter.
*/
static void db_sql_cgi(sqlite4_context *context, int argc, sqlite4_value **argv){
  const char* zP;
  if( argc!=1 && argc!=2 ) return;
  zP = P((const char*)sqlite4_value_text(argv[0]));
  if( zP ){
    sqlite4_result_text(context, zP, -1, SQLITE_STATIC);
    sqlite4_result_text(context, zP, -1, SQLITE4_STATIC);
  }else if( argc==2 ){
    zP = (const char*)sqlite4_value_text(argv[1]);
    if( zP ) sqlite4_result_text(context, zP, -1, SQLITE_TRANSIENT);
    if( zP ) sqlite4_result_text(context, zP, -1, SQLITE4_TRANSIENT);
  }
}

/*
** SQL function:
**
**       is_selected(id)
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475




1476
1477

1478
1479
1480

1481
1482
1483
1484
1485
1486
1487
1465
1466
1467
1468
1469
1470
1471




1472
1473
1474
1475
1476

1477
1478
1479

1480
1481
1482
1483
1484
1485
1486
1487







-
-
-
-
+
+
+
+

-
+


-
+








/*
** This function registers auxiliary functions when the SQLite
** database connection is first established.
*/
LOCAL void db_connection_init(void){
  sqlite4_exec(g.db, "PRAGMA foreign_keys=OFF;", 0, 0, 0);
  sqlite4_create_function(g.db, "user", 0, SQLITE_ANY, 0, db_sql_user, 0, 0);
  sqlite4_create_function(g.db, "cgi", 1, SQLITE_ANY, 0, db_sql_cgi, 0, 0);
  sqlite4_create_function(g.db, "cgi", 2, SQLITE_ANY, 0, db_sql_cgi, 0, 0);
  sqlite4_create_function(g.db, "print", -1, SQLITE_UTF8, 0,db_sql_print,0,0);
  sqlite4_create_function(g.db, "user", 0, SQLITE4_ANY, 0, db_sql_user, 0, 0);
  sqlite4_create_function(g.db, "cgi", 1, SQLITE4_ANY, 0, db_sql_cgi, 0, 0);
  sqlite4_create_function(g.db, "cgi", 2, SQLITE4_ANY, 0, db_sql_cgi, 0, 0);
  sqlite4_create_function(g.db, "print", -1, SQLITE4_UTF8, 0,db_sql_print,0,0);
  sqlite4_create_function(
    g.db, "is_selected", 1, SQLITE_UTF8, 0, file_is_selected,0,0
    g.db, "is_selected", 1, SQLITE4_UTF8, 0, file_is_selected,0,0
  );
  sqlite4_create_function(
    g.db, "if_selected", 3, SQLITE_UTF8, 0, file_is_selected,0,0
    g.db, "if_selected", 3, SQLITE4_UTF8, 0, file_is_selected,0,0
  );
  if( g.fSqlTrace ){
    sqlite4_trace(g.db, db_sql_trace, 0);
  }
}

/*
1672
1673
1674
1675
1676
1677
1678
1679

1680
1681
1682
1683
1684

1685
1686

1687
1688
1689
1690
1691
1692
1693
1672
1673
1674
1675
1676
1677
1678

1679
1680
1681
1682
1683

1684
1685

1686
1687
1688
1689
1690
1691
1692
1693







-
+




-
+

-
+







int db_get_int(const char *zName, int dflt){
  int v = dflt;
  int rc;
  if( g.repositoryOpen ){
    Stmt q;
    db_prepare(&q, "SELECT value FROM config WHERE name=%Q", zName);
    rc = db_step(&q);
    if( rc==SQLITE_ROW ){
    if( rc==SQLITE4_ROW ){
      v = db_column_int(&q, 0);
    }
    db_finalize(&q);
  }else{
    rc = SQLITE_DONE;
    rc = SQLITE4_DONE;
  }
  if( rc==SQLITE_DONE && g.configOpen ){
  if( rc==SQLITE4_DONE && g.configOpen ){
    db_swap_connections();
    v = db_int(dflt, "SELECT value FROM global_config WHERE name=%Q", zName);
    db_swap_connections();
  }
  return v;
}
void db_set_int(const char *zName, int value, int globalFlag){
1858
1859
1860
1861
1862
1863
1864
1865

1866
1867
1868
1869
1870
1871
1872
1858
1859
1860
1861
1862
1863
1864

1865
1866
1867
1868
1869
1870
1871
1872







-
+







    );
  }else{
    db_prepare(&q,
      "SELECT '(global)', value FROM global_config WHERE name=%Q",
      ctrlSetting->name
    );
  }
  if( db_step(&q)==SQLITE_ROW ){
  if( db_step(&q)==SQLITE4_ROW ){
    fossil_print("%-20s %-8s %s\n", ctrlSetting->name, db_column_text(&q, 0),
        db_column_text(&q, 1));
  }else{
    fossil_print("%-20s\n", ctrlSetting->name);
  }
  if( ctrlSetting->versionable && localOpen ){
    /* Check to see if this is overridden by a versionable settings file */
2193
2194
2195
2196
2197
2198
2199
2200

2201
2202
2203
2204
2205
2193
2194
2195
2196
2197
2198
2199

2200
2201
2202
2203
2204
2205







-
+





** %fossil test-timespan TIMESTAMP
**
** Print the approximate span of time from now to TIMESTAMP.
*/
void test_timespan_cmd(void){
  double rDiff;
  if( g.argc!=3 ) usage("TIMESTAMP");
  sqlite4_open(0, ":memory:", &g.db, SQLITE_OPEN_READWRITE);  
  sqlite4_open(0, ":memory:", &g.db, SQLITE4_OPEN_READWRITE);  
  rDiff = db_double(0.0, "SELECT julianday('now') - julianday(%Q)", g.argv[2]);
  fossil_print("Time differences: %s\n", db_timespan_name(rDiff));
  sqlite4_close(g.db);
  g.db = 0;
}