Hex Artifact Content

Not logged in

Artifact a34c39ae7aa50b772ce8bd523cfdf9443a3718cf:


0000: 23 69 66 20 64 65 66 69 6e 65 64 28 4e 44 45 42  #if defined(NDEB
0010: 55 47 29 0a 23 20 20 75 6e 64 65 66 20 4e 44 45  UG).#  undef NDE
0020: 42 55 47 20 2f 2a 20 66 6f 72 63 65 20 61 73 73  BUG /* force ass
0030: 65 72 74 28 29 20 74 6f 20 61 6c 77 61 79 73 20  ert() to always 
0040: 77 6f 72 6b 20 2a 2f 0a 23 65 6e 64 69 66 0a 23  work */.#endif.#
0050: 69 6e 63 6c 75 64 65 20 3c 61 73 73 65 72 74 2e  include <assert.
0060: 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c 73 74 64  h>.#include <std
0070: 69 6f 2e 68 3e 0a 23 69 6e 63 6c 75 64 65 20 3c  io.h>.#include <
0080: 73 74 64 6c 69 62 2e 68 3e 20 2f 2a 20 61 74 65  stdlib.h> /* ate
0090: 78 69 74 28 29 20 2a 2f 0a 23 69 6e 63 6c 75 64  xit() */.#includ
00a0: 65 20 22 77 68 2f 63 73 6f 6e 2f 63 73 6f 6e 5f  e "wh/cson/cson_
00b0: 73 71 6c 69 74 65 33 2e 68 22 0a 0a 23 64 65 66  sqlite3.h"..#def
00c0: 69 6e 65 20 4d 41 52 4b 45 52 20 69 66 28 31 29  ine MARKER if(1)
00d0: 20 70 72 69 6e 74 66 28 22 4d 41 52 4b 45 52 3a   printf("MARKER:
00e0: 20 25 73 3a 25 64 3a 25 73 28 29 3a 5c 74 22 2c   %s:%d:%s():\t",
00f0: 5f 5f 46 49 4c 45 5f 5f 2c 5f 5f 4c 49 4e 45 5f  __FILE__,__LINE_
0100: 5f 2c 5f 5f 66 75 6e 63 5f 5f 29 3b 20 69 66 28  _,__func__); if(
0110: 31 29 20 70 72 69 6e 74 66 0a 23 64 65 66 69 6e  1) printf.#defin
0120: 65 20 53 48 4f 57 52 43 28 52 43 29 20 4d 41 52  e SHOWRC(RC) MAR
0130: 4b 45 52 28 22 72 63 3d 25 64 20 28 25 73 29 5c  KER("rc=%d (%s)\
0140: 6e 22 2c 52 43 2c 63 73 6f 6e 5f 72 63 5f 73 74  n",RC,cson_rc_st
0150: 72 69 6e 67 28 52 43 29 29 0a 0a 73 74 61 74 69  ring(RC))..stati
0160: 63 20 73 74 72 75 63 74 20 7b 0a 20 20 20 20 73  c struct {.    s
0170: 71 6c 69 74 65 33 20 2a 20 64 62 3b 0a 20 20 20  qlite3 * db;.   
0180: 20 63 68 61 72 20 63 6f 6e 73 74 20 2a 20 66 6e   char const * fn
0190: 61 6d 65 3b 0a 20 20 20 20 63 73 6f 6e 5f 6f 75  ame;.    cson_ou
01a0: 74 70 75 74 5f 6f 70 74 20 6f 75 74 4f 70 74 3b  tput_opt outOpt;
01b0: 0a 7d 20 54 68 69 73 41 70 70 20 3d 20 7b 0a 20  .} ThisApp = {. 
01c0: 20 20 20 4e 55 4c 4c 2f 2a 64 62 2a 2f 2c 0a 20     NULL/*db*/,. 
01d0: 20 20 20 22 3a 6d 65 6d 6f 72 79 3a 22 2f 2a 66     ":memory:"/*f
01e0: 6e 61 6d 65 2a 2f 2c 0a 20 20 20 20 63 73 6f 6e  name*/,.    cson
01f0: 5f 6f 75 74 70 75 74 5f 6f 70 74 5f 65 6d 70 74  _output_opt_empt
0200: 79 5f 6d 0a 7d 3b 0a 0a 73 74 61 74 69 63 20 76  y_m.};..static v
0210: 6f 69 64 20 73 65 74 75 70 5f 64 62 28 29 0a 7b  oid setup_db().{
0220: 0a 20 20 20 20 4d 41 52 4b 45 52 28 22 64 62 20  .    MARKER("db 
0230: 73 65 74 75 70 20 73 74 61 72 74 69 6e 67 20 5b  setup starting [
0240: 66 69 6c 65 3d 25 73 5d 2e 2e 2e 5c 6e 22 2c 20  file=%s]...\n", 
0250: 54 68 69 73 41 70 70 2e 66 6e 61 6d 65 29 3b 0a  ThisApp.fname);.
0260: 20 20 20 20 69 6e 74 20 72 63 20 3d 20 73 71 6c      int rc = sql
0270: 69 74 65 33 5f 6f 70 65 6e 5f 76 32 28 20 54 68  ite3_open_v2( Th
0280: 69 73 41 70 70 2e 66 6e 61 6d 65 2c 20 26 54 68  isApp.fname, &Th
0290: 69 73 41 70 70 2e 64 62 2c 20 0a 20 20 20 20 20  isApp.db, .     
02a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
02b0: 20 20 20 20 20 20 20 53 51 4c 49 54 45 5f 4f 50         SQLITE_OP
02c0: 45 4e 5f 52 45 41 44 57 52 49 54 45 20 7c 20 53  EN_READWRITE | S
02d0: 51 4c 49 54 45 5f 4f 50 45 4e 5f 43 52 45 41 54  QLITE_OPEN_CREAT
02e0: 45 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20  E,.             
02f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4e                 N
0300: 55 4c 4c 20 29 3b 0a 20 20 20 20 61 73 73 65 72  ULL );.    asser
0310: 74 28 20 28 30 20 3d 3d 20 72 63 29 20 26 26 20  t( (0 == rc) && 
0320: 22 64 62 20 6f 70 65 6e 20 66 61 69 6c 65 64 21  "db open failed!
0330: 22 20 29 3b 0a 0a 23 64 65 66 69 6e 65 20 52 55  " );..#define RU
0340: 4e 53 51 4c 28 53 51 4c 29 20 5c 0a 20 20 20 20  NSQL(SQL) \.    
0350: 70 75 74 73 28 53 51 4c 29 3b 20 5c 0a 20 20 20  puts(SQL); \.   
0360: 20 72 63 20 3d 20 73 71 6c 69 74 65 33 5f 65 78   rc = sqlite3_ex
0370: 65 63 28 20 54 68 69 73 41 70 70 2e 64 62 2c 20  ec( ThisApp.db, 
0380: 53 51 4c 2c 20 4e 55 4c 4c 2c 20 4e 55 4c 4c 2c  SQL, NULL, NULL,
0390: 20 4e 55 4c 4c 20 29 3b 20 5c 0a 20 20 20 20 61   NULL ); \.    a
03a0: 73 73 65 72 74 28 20 28 30 20 3d 3d 20 72 63 29  ssert( (0 == rc)
03b0: 20 26 26 20 22 51 55 45 52 59 20 46 41 49 4c 45   && "QUERY FAILE
03c0: 44 22 29 0a 0a 20 20 20 20 63 68 61 72 20 63 6f  D")..    char co
03d0: 6e 73 74 20 2a 20 73 71 6c 20 3d 20 22 43 52 45  nst * sql = "CRE
03e0: 41 54 45 20 54 41 42 4c 45 20 49 46 20 4e 4f 54  ATE TABLE IF NOT
03f0: 20 45 58 49 53 54 53 20 73 74 75 66 66 20 28 22   EXISTS stuff ("
0400: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20  .               
0410: 20 20 20 20 20 20 20 20 20 22 6e 61 6d 65 20 55           "name U
0420: 4e 49 51 55 45 20 4f 4e 20 43 4f 4e 46 4c 49 43  NIQUE ON CONFLIC
0430: 54 20 52 45 50 4c 41 43 45 2c 20 22 0a 20 20 20  T REPLACE, ".   
0440: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0450: 20 20 20 20 20 22 63 6f 75 6e 74 20 74 69 6e 79       "count tiny
0460: 69 6e 74 28 31 29 22 0a 20 20 20 20 20 20 20 20  int(1)".        
0470: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
0480: 22 29 3b 22 3b 0a 20 20 20 20 52 55 4e 53 51 4c  ");";.    RUNSQL
0490: 28 73 71 6c 29 3b 0a 20 20 20 20 52 55 4e 53 51  (sql);.    RUNSQ
04a0: 4c 28 22 44 45 4c 45 54 45 20 46 52 4f 4d 20 73  L("DELETE FROM s
04b0: 74 75 66 66 22 29 3b 0a 20 20 20 20 52 55 4e 53  tuff");.    RUNS
04c0: 51 4c 28 22 49 4e 53 45 52 54 20 49 4e 54 4f 20  QL("INSERT INTO 
04d0: 53 54 55 46 46 20 28 6e 61 6d 65 2c 63 6f 75 6e  STUFF (name,coun
04e0: 74 29 20 56 41 4c 55 45 53 28 27 74 68 69 73 27  t) VALUES('this'
04f0: 2c 33 29 22 20 29 3b 0a 20 20 20 20 52 55 4e 53  ,3)" );.    RUNS
0500: 51 4c 28 22 49 4e 53 45 52 54 20 49 4e 54 4f 20  QL("INSERT INTO 
0510: 53 54 55 46 46 20 28 6e 61 6d 65 2c 63 6f 75 6e  STUFF (name,coun
0520: 74 29 20 56 41 4c 55 45 53 28 27 74 68 61 74 27  t) VALUES('that'
0530: 2c 32 29 22 20 29 3b 0a 20 20 20 20 52 55 4e 53  ,2)" );.    RUNS
0540: 51 4c 28 22 49 4e 53 45 52 54 20 49 4e 54 4f 20  QL("INSERT INTO 
0550: 53 54 55 46 46 20 28 6e 61 6d 65 2c 63 6f 75 6e  STUFF (name,coun
0560: 74 29 20 56 41 4c 55 45 53 28 27 69 6e 74 5a 65  t) VALUES('intZe
0570: 72 6f 27 2c 30 29 22 20 29 3b 0a 20 20 20 20 52  ro',0)" );.    R
0580: 55 4e 53 51 4c 28 22 49 4e 53 45 52 54 20 49 4e  UNSQL("INSERT IN
0590: 54 4f 20 53 54 55 46 46 20 28 6e 61 6d 65 2c 63  TO STUFF (name,c
05a0: 6f 75 6e 74 29 20 56 41 4c 55 45 53 28 27 64 6f  ount) VALUES('do
05b0: 75 62 6c 65 5a 65 72 6f 27 2c 30 2e 30 29 22 20  ubleZero',0.0)" 
05c0: 29 3b 0a 20 20 20 20 52 55 4e 53 51 4c 28 22 49  );.    RUNSQL("I
05d0: 4e 53 45 52 54 20 49 4e 54 4f 20 53 54 55 46 46  NSERT INTO STUFF
05e0: 20 28 6e 61 6d 65 2c 63 6f 75 6e 74 29 20 56 41   (name,count) VA
05f0: 4c 55 45 53 28 27 65 6d 70 74 79 53 74 72 69 6e  LUES('emptyStrin
0600: 67 27 2c 27 27 29 22 20 29 3b 0a 20 20 20 20 52  g','')" );.    R
0610: 55 4e 53 51 4c 28 22 49 4e 53 45 52 54 20 49 4e  UNSQL("INSERT IN
0620: 54 4f 20 53 54 55 46 46 20 28 6e 61 6d 65 2c 63  TO STUFF (name,c
0630: 6f 75 6e 74 29 20 56 41 4c 55 45 53 28 27 6e 75  ount) VALUES('nu
0640: 6c 6c 56 61 6c 75 65 27 2c 4e 55 4c 4c 29 22 20  llValue',NULL)" 
0650: 29 3b 0a 23 75 6e 64 65 66 20 52 55 4e 53 51 4c  );.#undef RUNSQL
0660: 0a 0a 20 20 20 20 63 73 6f 6e 5f 76 61 6c 75 65  ..    cson_value
0670: 20 2a 20 78 20 3d 20 63 73 6f 6e 5f 76 61 6c 75   * x = cson_valu
0680: 65 5f 6e 65 77 5f 73 74 72 69 6e 67 28 22 68 69  e_new_string("hi
0690: 21 22 2c 33 29 3b 0a 20 20 20 20 63 73 6f 6e 5f  !",3);.    cson_
06a0: 76 61 6c 75 65 20 2a 20 79 20 3d 20 63 73 6f 6e  value * y = cson
06b0: 5f 76 61 6c 75 65 5f 6e 65 77 5f 69 6e 74 65 67  _value_new_integ
06c0: 65 72 28 34 32 29 3b 0a 20 20 20 20 63 73 6f 6e  er(42);.    cson
06d0: 5f 61 72 72 61 79 20 2a 20 61 72 20 3d 20 63 73  _array * ar = cs
06e0: 6f 6e 5f 6e 65 77 5f 61 72 72 61 79 28 29 3b 0a  on_new_array();.
06f0: 20 20 20 20 63 73 6f 6e 5f 61 72 72 61 79 5f 61      cson_array_a
0700: 70 70 65 6e 64 28 61 72 2c 20 78 29 3b 0a 20 20  ppend(ar, x);.  
0710: 20 20 63 73 6f 6e 5f 61 72 72 61 79 5f 61 70 70    cson_array_app
0720: 65 6e 64 28 61 72 2c 20 79 29 3b 0a 20 20 20 20  end(ar, y);.    
0730: 73 71 6c 69 74 65 33 5f 73 74 6d 74 20 2a 20 73  sqlite3_stmt * s
0740: 74 20 3d 20 4e 55 4c 4c 3b 0a 20 20 20 20 72 63  t = NULL;.    rc
0750: 20 3d 20 73 71 6c 69 74 65 33 5f 70 72 65 70 61   = sqlite3_prepa
0760: 72 65 5f 76 32 28 20 54 68 69 73 41 70 70 2e 64  re_v2( ThisApp.d
0770: 62 2c 20 22 49 4e 53 45 52 54 20 49 4e 54 4f 20  b, "INSERT INTO 
0780: 53 54 55 46 46 28 6e 61 6d 65 2c 63 6f 75 6e 74  STUFF(name,count
0790: 29 20 56 41 4c 55 45 53 28 3f 2c 3f 29 22 2c 0a  ) VALUES(?,?)",.
07a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20                  
07b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 2d 31 2c               -1,
07c0: 20 26 73 74 2c 20 4e 55 4c 4c 29 3b 0a 20 20 20   &st, NULL);.   
07d0: 20 63 73 6f 6e 5f 73 71 6c 69 74 65 33 5f 62 69   cson_sqlite3_bi
07e0: 6e 64 5f 76 61 6c 75 65 28 20 73 74 2c 20 31 2c  nd_value( st, 1,
07f0: 20 63 73 6f 6e 5f 61 72 72 61 79 5f 76 61 6c 75   cson_array_valu
0800: 65 28 61 72 29 20 29 3b 0a 20 20 20 20 63 73 6f  e(ar) );.    cso
0810: 6e 5f 66 72 65 65 5f 61 72 72 61 79 28 61 72 29  n_free_array(ar)
0820: 3b 0a 20 20 20 20 72 63 20 3d 20 73 71 6c 69 74  ;.    rc = sqlit
0830: 65 33 5f 73 74 65 70 28 73 74 29 3b 0a 20 20 20  e3_step(st);.   
0840: 20 61 73 73 65 72 74 28 53 51 4c 49 54 45 5f 44   assert(SQLITE_D
0850: 4f 4e 45 3d 3d 72 63 29 3b 0a 20 20 20 20 73 71  ONE==rc);.    sq
0860: 6c 69 74 65 33 5f 66 69 6e 61 6c 69 7a 65 28 73  lite3_finalize(s
0870: 74 29 3b 0a 20 20 20 20 4d 41 52 4b 45 52 28 22  t);.    MARKER("
0880: 64 62 20 73 65 74 75 70 20 64 6f 6e 65 2e 5c 6e  db setup done.\n
0890: 22 29 3b 0a 7d 0a 0a 0a 73 74 61 74 69 63 20 76  ");.}...static v
08a0: 6f 69 64 20 74 65 73 74 31 28 29 0a 7b 0a 20 20  oid test1().{.  
08b0: 20 20 4d 41 52 4b 45 52 28 22 74 65 73 74 31 28    MARKER("test1(
08c0: 29 20 73 74 61 72 74 69 6e 67 2e 5c 6e 22 29 3b  ) starting.\n");
08d0: 0a 20 20 20 20 61 73 73 65 72 74 28 20 4e 55 4c  .    assert( NUL
08e0: 4c 20 21 3d 20 54 68 69 73 41 70 70 2e 64 62 20  L != ThisApp.db 
08f0: 29 3b 0a 20 20 20 20 0a 20 20 20 20 73 71 6c 69  );.    .    sqli
0900: 74 65 33 5f 73 74 6d 74 20 2a 20 73 74 20 3d 20  te3_stmt * st = 
0910: 4e 55 4c 4c 3b 0a 20 20 20 20 63 68 61 72 20 63  NULL;.    char c
0920: 6f 6e 73 74 20 2a 20 73 65 6c 65 63 74 20 3d 20  onst * select = 
0930: 22 53 45 4c 45 43 54 20 2a 20 46 52 4f 4d 20 73  "SELECT * FROM s
0940: 74 75 66 66 22 3b 0a 20 20 20 20 69 6e 74 20 72  tuff";.    int r
0950: 63 20 3d 20 73 71 6c 69 74 65 33 5f 70 72 65 70  c = sqlite3_prep
0960: 61 72 65 5f 76 32 28 20 54 68 69 73 41 70 70 2e  are_v2( ThisApp.
0970: 64 62 2c 20 73 65 6c 65 63 74 2c 20 2d 31 2c 0a  db, select, -1,.
0980: 20 20 20 20 20 20 20 20 20 20 20 20 26 73 74 2c              &st,
0990: 20 4e 55 4c 4c 20 29 3b 0a 20 20 20 20 61 73 73   NULL );.    ass
09a0: 65 72 74 28 20 30 20 3d 3d 20 72 63 20 29 3b 0a  ert( 0 == rc );.
09b0: 20 20 20 20 63 73 6f 6e 5f 76 61 6c 75 65 20 2a      cson_value *
09c0: 20 6a 73 6f 6e 20 3d 20 4e 55 4c 4c 3b 0a 20 20   json = NULL;.  
09d0: 20 20 63 68 61 72 20 66 61 74 20 3d 20 31 3b 0a    char fat = 1;.
09e0: 20 20 20 20 72 63 20 3d 20 63 73 6f 6e 5f 73 71      rc = cson_sq
09f0: 6c 69 74 65 33 5f 73 74 6d 74 5f 74 6f 5f 6a 73  lite3_stmt_to_js
0a00: 6f 6e 28 20 73 74 2c 20 26 6a 73 6f 6e 2c 20 66  on( st, &json, f
0a10: 61 74 20 29 3b 0a 20 20 20 20 73 71 6c 69 74 65  at );.    sqlite
0a20: 33 5f 66 69 6e 61 6c 69 7a 65 28 73 74 29 3b 0a  3_finalize(st);.
0a30: 20 20 20 20 61 73 73 65 72 74 28 20 30 20 3d 3d      assert( 0 ==
0a40: 20 72 63 20 29 3b 0a 20 20 20 20 61 73 73 65 72   rc );.    asser
0a50: 74 28 20 4e 55 4c 4c 20 21 3d 20 6a 73 6f 6e 20  t( NULL != json 
0a60: 29 3b 0a 20 20 20 20 4d 41 52 4b 45 52 28 22 56  );.    MARKER("V
0a70: 69 61 20 63 73 6f 6e 5f 73 71 6c 69 74 65 33 5f  ia cson_sqlite3_
0a80: 73 74 6d 74 5f 74 6f 5f 6a 73 6f 6e 28 25 73 20  stmt_to_json(%s 
0a90: 6d 6f 64 65 29 20 5b 25 73 5d 2e 2e 2e 5c 6e 22  mode) [%s]...\n"
0aa0: 2c 66 61 74 3f 22 66 61 74 22 3a 22 73 6c 69 6d  ,fat?"fat":"slim
0ab0: 22 2c 73 65 6c 65 63 74 29 3b 0a 20 20 20 20 63  ",select);.    c
0ac0: 73 6f 6e 5f 6f 75 74 70 75 74 5f 46 49 4c 45 28  son_output_FILE(
0ad0: 20 6a 73 6f 6e 2c 20 73 74 64 6f 75 74 2c 20 26   json, stdout, &
0ae0: 54 68 69 73 41 70 70 2e 6f 75 74 4f 70 74 20 29  ThisApp.outOpt )
0af0: 3b 0a 20 20 20 20 63 73 6f 6e 5f 76 61 6c 75 65  ;.    cson_value
0b00: 5f 66 72 65 65 28 6a 73 6f 6e 29 3b 0a 20 20 20  _free(json);.   
0b10: 20 6a 73 6f 6e 20 3d 20 4e 55 4c 4c 3b 0a 20 20   json = NULL;.  
0b20: 20 20 66 61 74 20 3d 20 21 66 61 74 3b 0a 20 20    fat = !fat;.  
0b30: 20 20 72 63 20 3d 20 63 73 6f 6e 5f 73 71 6c 69    rc = cson_sqli
0b40: 74 65 33 5f 73 71 6c 5f 74 6f 5f 6a 73 6f 6e 28  te3_sql_to_json(
0b50: 20 54 68 69 73 41 70 70 2e 64 62 2c 20 26 6a 73   ThisApp.db, &js
0b60: 6f 6e 2c 20 73 65 6c 65 63 74 2c 20 66 61 74 29  on, select, fat)
0b70: 3b 0a 20 20 20 20 61 73 73 65 72 74 28 20 30 20  ;.    assert( 0 
0b80: 3d 3d 20 72 63 20 29 3b 0a 20 20 20 20 4d 41 52  == rc );.    MAR
0b90: 4b 45 52 28 22 56 69 61 20 63 73 6f 6e 5f 73 71  KER("Via cson_sq
0ba0: 6c 69 74 65 33 5f 73 71 6c 5f 74 6f 5f 6a 73 6f  lite3_sql_to_jso
0bb0: 6e 28 25 73 20 6d 6f 64 65 29 20 5b 25 73 5d 2e  n(%s mode) [%s].
0bc0: 2e 2e 5c 6e 22 2c 66 61 74 3f 22 66 61 74 22 3a  ..\n",fat?"fat":
0bd0: 22 73 6c 69 6d 22 2c 73 65 6c 65 63 74 29 3b 0a  "slim",select);.
0be0: 20 20 20 20 63 73 6f 6e 5f 6f 75 74 70 75 74 5f      cson_output_
0bf0: 46 49 4c 45 28 20 6a 73 6f 6e 2c 20 73 74 64 6f  FILE( json, stdo
0c00: 75 74 2c 20 26 54 68 69 73 41 70 70 2e 6f 75 74  ut, &ThisApp.out
0c10: 4f 70 74 20 29 3b 0a 20 20 20 20 63 73 6f 6e 5f  Opt );.    cson_
0c20: 76 61 6c 75 65 5f 66 72 65 65 28 6a 73 6f 6e 29  value_free(json)
0c30: 3b 0a 20 20 20 20 4d 41 52 4b 45 52 28 22 74 65  ;.    MARKER("te
0c40: 73 74 31 28 29 20 64 6f 6e 65 2e 5c 6e 22 29 3b  st1() done.\n");
0c50: 0a 7d 0a 0a 73 74 61 74 69 63 20 76 6f 69 64 20  .}..static void 
0c60: 61 74 65 78 69 74 5f 68 61 6e 64 6c 65 72 28 29  atexit_handler()
0c70: 0a 7b 0a 20 20 20 20 69 66 28 20 4e 55 4c 4c 20  .{.    if( NULL 
0c80: 21 3d 20 54 68 69 73 41 70 70 2e 64 62 20 29 20  != ThisApp.db ) 
0c90: 7b 0a 20 20 20 20 20 20 20 20 73 71 6c 69 74 65  {.        sqlite
0ca0: 33 5f 63 6c 6f 73 65 28 54 68 69 73 41 70 70 2e  3_close(ThisApp.
0cb0: 64 62 29 3b 0a 20 20 20 20 20 20 20 20 54 68 69  db);.        Thi
0cc0: 73 41 70 70 2e 64 62 20 3d 20 4e 55 4c 4c 3b 0a  sApp.db = NULL;.
0cd0: 20 20 20 20 7d 0a 7d 0a 69 6e 74 20 6d 61 69 6e      }.}.int main
0ce0: 28 69 6e 74 20 61 72 67 63 2c 20 63 68 61 72 20  (int argc, char 
0cf0: 2a 2a 61 72 67 76 29 0a 7b 0a 20 20 20 20 61 74  **argv).{.    at
0d00: 65 78 69 74 28 20 61 74 65 78 69 74 5f 68 61 6e  exit( atexit_han
0d10: 64 6c 65 72 20 29 3b 0a 20 20 20 20 73 65 74 75  dler );.    setu
0d20: 70 5f 64 62 28 29 3b 0a 20 20 20 20 54 68 69 73  p_db();.    This
0d30: 41 70 70 2e 6f 75 74 4f 70 74 2e 61 64 64 4e 65  App.outOpt.addNe
0d40: 77 6c 69 6e 65 20 3d 20 31 3b 0a 20 20 20 20 54  wline = 1;.    T
0d50: 68 69 73 41 70 70 2e 6f 75 74 4f 70 74 2e 69 6e  hisApp.outOpt.in
0d60: 64 65 6e 74 61 74 69 6f 6e 20 3d 20 30 3b 0a 20  dentation = 0;. 
0d70: 20 20 20 74 65 73 74 31 28 29 3b 0a 09 72 65 74     test1();..ret
0d80: 75 72 6e 20 30 3b 0a 7d 0a                       urn 0;.}.