SQLite4
Check-in [fde11ff78c]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:fde11ff78c433d669c3aea05aa77b58b0f3ef393
Date: 2013-03-28 19:41:30
User: dan
Comment:Add tests to sqltest.
Tags And Properties
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to lsm-test/sqltest.c

50
51
52
53
54
55
56












57
58
59
60
61
62
63
...
158
159
160
161
162
163
164










































165
166
167
168
169
170
171
...
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
...
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
...
523
524
525
526
527
528
529
530
















































































































































































































































































































































































































531
532
533
534
535
536
537


538
539
540
541
542
543
544

  if( zBase!=zDb ){
    sqlite4_free(0, zBase);
  }
  return 0;
}













static char *create_schema_sql(int nIdx){
  char *zSchema;
  int i;

  zSchema = sqlite4_mprintf(0, "CREATE TABLE t1(k PRIMARY KEY,");
  for(i=0; i<nIdx; i++){
    zSchema = sqlite4_mprintf(0, "%z c%d BLOB,", zSchema, i);
................................................................................
static void install_rblob_function3(sqlite3 *db){
  testPrngInit();
  sqlite3_create_function(db, "rblob", 3, SQLITE_UTF8, 0, rblobFunc3, 0, 0);
}
/*
** End of rblob() implementations.
*************************************************************************/











































/*************************************************************************
** Integer query functions for sqlite3 and src4.
*/
static int integer_query4(sqlite4 *db, const char *zSql){
  int iRet;
  sqlite4_stmt *pStmt;
................................................................................
  int nMs = 0;
  sqlite3_stmt *pSelect = 0;
  char *zSelect;
  sqlite3 *db;
  int i;
  int nTblRow;
  

  if( zFile==0 ) zFile = SQLITE3_DB_FILE;
  EXPLODE( sqlite3_open(zFile, &db) );
  install_rblob_function3(db);

  nTblRow = integer_query3(db, "SELECT count(*) FROM t1");

  /* Create the db schema and prepare the INSERT statement */
................................................................................
    if( 0==strcmp("-file", aArg[iSel].zArg) ){
      zFile = argv[++i];
    }else{
      int iVal = atoi(argv[++i]);
      if( iVal<aArg[iSel].nMin || iVal>aArg[iSel].nMax ){
        fprintf(stderr, "option %s out of range (%d..%d)\n", 
            aArg[iSel].zArg, aArg[iSel].nMin, aArg[iSel].nMax 
            );
        return -1;
      }

      switch( iSel ){
        case 0: iDb = iVal;          break;
        case 1: nRow = iVal;         break;
        case 2: nRowPerTrans = iVal; break;
................................................................................
    do_select1_test3(zFile, nRow, nRowPerTrans, iIdx);
  }else{
    do_select1_test4(zFile, nRow, nRowPerTrans, iIdx);
  }

  return 0;
}

















































































































































































































































































































































































































int main(int argc, char **argv){
  struct SqltestArg {
    const char *zPrg;
    int (*xPrg)(int, char **);
  } aArg[] = { 
    {"select", do_select1},
    {"insert", do_insert1},


    {0, 0}
  };
  int iSel;
  int rc;

  if( argc<2 ){
    fprintf(stderr, "Usage: %s sub-program...\n", argv[0]);







>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







<







 







|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







>
>







50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
...
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
...
482
483
484
485
486
487
488

489
490
491
492
493
494
495
...
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
...
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
630
631
632
633
634
635
636
637
638
639
640
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
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999

  if( zBase!=zDb ){
    sqlite4_free(0, zBase);
  }
  return 0;
}

/*
** Allocate and return a buffer containing the text of CREATE TABLE 
** and CREATE INDEX statements to use as the database schema for the [insert]
** and [select] tests. The schema is similar to:
**
**     CREATE TABLE t1(k PRIMARY KEY, c0 BLOB, c1 BLOB, v BLOB);
**     CREATE INDEX i0 ON t1(c0);
**     CREATE INDEX i1 ON t1(c1);
**
** where the number of "c" columns (and indexes) is determined by the nIdx
** argument. The example above is as would be returned for nIdx==2.
*/
static char *create_schema_sql(int nIdx){
  char *zSchema;
  int i;

  zSchema = sqlite4_mprintf(0, "CREATE TABLE t1(k PRIMARY KEY,");
  for(i=0; i<nIdx; i++){
    zSchema = sqlite4_mprintf(0, "%z c%d BLOB,", zSchema, i);
................................................................................
static void install_rblob_function3(sqlite3 *db){
  testPrngInit();
  sqlite3_create_function(db, "rblob", 3, SQLITE_UTF8, 0, rblobFunc3, 0, 0);
}
/*
** End of rblob() implementations.
*************************************************************************/

/*************************************************************************
** Implementations of the rint(iSeed, nRange) function. One for src4 and
** one for sqlite3.
*/

/* sqlite3 implementation */
static void rintFunc3(sqlite3_context *ctx, int nArg, sqlite3_value **apArg){
  int iVal;
  int iSeed = sqlite3_value_int(apArg[0]);
  int nRange = sqlite3_value_int(apArg[1]);

  iVal = testPrngValue(iSeed) & 0x7FFFFFFF;
  if( nRange>0 ){
    iVal = iVal % nRange;
  }
  sqlite3_result_int(ctx, iVal);
}
static void install_rint_function3(sqlite3 *db){
  testPrngInit();
  sqlite3_create_function(db, "rint", 2, SQLITE_UTF8, 0, rintFunc3, 0, 0);
}

/* src4 implementation */
static void rintFunc4(sqlite4_context *ctx, int nArg, sqlite4_value **apArg){
  int iVal;
  int iSeed = sqlite4_value_int(apArg[0]);
  int nRange = sqlite4_value_int(apArg[1]);

  iVal = testPrngValue(iSeed) & 0x7FFFFFFF;
  if( nRange>0 ){
    iVal = iVal % nRange;
  }
  sqlite4_result_int(ctx, iVal);
}
static void install_rint_function4(sqlite4 *db){
  testPrngInit();
  sqlite4_create_function(db, "rint", 2, SQLITE4_UTF8, 0, rintFunc4, 0, 0);
}
/*
** End of rint() implementations.
*************************************************************************/

/*************************************************************************
** Integer query functions for sqlite3 and src4.
*/
static int integer_query4(sqlite4 *db, const char *zSql){
  int iRet;
  sqlite4_stmt *pStmt;
................................................................................
  int nMs = 0;
  sqlite3_stmt *pSelect = 0;
  char *zSelect;
  sqlite3 *db;
  int i;
  int nTblRow;
  

  if( zFile==0 ) zFile = SQLITE3_DB_FILE;
  EXPLODE( sqlite3_open(zFile, &db) );
  install_rblob_function3(db);

  nTblRow = integer_query3(db, "SELECT count(*) FROM t1");

  /* Create the db schema and prepare the INSERT statement */
................................................................................
    if( 0==strcmp("-file", aArg[iSel].zArg) ){
      zFile = argv[++i];
    }else{
      int iVal = atoi(argv[++i]);
      if( iVal<aArg[iSel].nMin || iVal>aArg[iSel].nMax ){
        fprintf(stderr, "option %s out of range (%d..%d)\n", 
            aArg[iSel].zArg, aArg[iSel].nMin, aArg[iSel].nMax 
        );
        return -1;
      }

      switch( iSel ){
        case 0: iDb = iVal;          break;
        case 1: nRow = iVal;         break;
        case 2: nRowPerTrans = iVal; break;
................................................................................
    do_select1_test3(zFile, nRow, nRowPerTrans, iIdx);
  }else{
    do_select1_test4(zFile, nRow, nRowPerTrans, iIdx);
  }

  return 0;
}

typedef struct SqlDatabase  SqlDatabase;
typedef struct SqlStmt SqlStmt;
typedef struct SqlDatabase3 SqlDatabase3;
typedef struct SqlDatabase4 SqlDatabase4;
struct SqlStmt {
  char *zStmt;
  void *pStmt;
  SqlStmt *pNext;
};
struct SqlDatabase {
  int iDb;                        /* SQLite version (3 or 4) */
  SqlStmt *pSqlStmt;
};
struct SqlDatabase3 {
  SqlDatabase x;                  /* Must be first */
  sqlite3 *db;
};
struct SqlDatabase4 {
  SqlDatabase x;                  /* Must be first */
  sqlite4 *db;
};

static int open_database(
  int iDb, 
  const char *zConfig,
  const char *zFile, 
  int bNew,
  SqlDatabase **pp
){
  int rc = 0;

  assert( iDb==3 || iDb==4 );
  if( zFile==0 ){
    if( iDb==3 ){
      zFile = SQLITE3_DB_FILE;
    }else{
      zFile = SQLITE4_DB_FILE;
    }
  }

  if( bNew ){
    unlink_db(zFile);
  }

  if( iDb==3 ){
    SqlDatabase3 *p = sqlite4_malloc(0, sizeof(SqlDatabase4));
    memset(p, 0, sizeof(SqlDatabase3));
    p->x.iDb = 3;
    rc = sqlite3_open(zFile, &p->db);
    if( rc!=SQLITE_OK ){
      sqlite4_free(0, p);
      p = 0;
    }else{
      sqlite3_exec(p->db, "PRAGMA synchronous=NORMAL", 0, 0, 0);
      sqlite3_exec(p->db, "PRAGMA journal_mode=WAL", 0, 0, 0);
      install_rint_function3(p->db);
      if( zConfig ) {
        rc = sqlite3_exec(p->db, zConfig, 0, 0, 0);
      }
    }
    *pp = (SqlDatabase *)p;
  }else{
    SqlDatabase4 *p = sqlite4_malloc(0, sizeof(SqlDatabase4));
    memset(p, 0, sizeof(SqlDatabase4));
    p->x.iDb = 4;
    rc = sqlite4_open(0, zFile, &p->db);
    if( rc!=SQLITE4_OK ){
      sqlite4_free(0, p);
      p = 0;
    }else{
      install_rint_function4(p->db);
      if( zConfig ) {
        rc = sqlite4_exec(p->db, zConfig, 0, 0, 0);
      }
    }
    *pp = (SqlDatabase *)p;
  }

  return rc;
}

static void close_database(SqlDatabase *pDb){
  assert( pDb->iDb==3 || pDb->iDb==4 );
  if( pDb->iDb==3 ){
    SqlDatabase3 *p = (SqlDatabase3 *)pDb;
    SqlStmt *pSql;
    SqlStmt *pNext;
    for(pSql=pDb->pSqlStmt; pSql; pSql=pNext){
      pNext = pSql->pNext;
      sqlite3_finalize((sqlite3_stmt *)pSql->pStmt);
      sqlite4_free(0, pSql);
    }
    sqlite3_close(p->db);
    sqlite4_free(0, p);
  }else{
    SqlDatabase4 *p = (SqlDatabase4 *)pDb;
    SqlStmt *pSql;
    SqlStmt *pNext;
    for(pSql=pDb->pSqlStmt; pSql; pSql=pNext){
      pNext = pSql->pNext;
      sqlite4_finalize((sqlite4_stmt *)pSql->pStmt);
      sqlite4_free(0, pSql);
    }
    sqlite4_close(p->db);
    sqlite4_free(0, p);
  }
}

static int exec_sql(SqlDatabase *pDb, const char *zSql, const char *zBind, ...){
  int rc = 0;
  void *pNewStmt = 0;
  SqlStmt *pSql;

  /* Search for an existing prepared statement. */
  for(pSql=pDb->pSqlStmt; pSql && strcmp(pSql->zStmt, zSql); pSql=pSql->pNext);

  assert( pDb->iDb==3 || pDb->iDb==4 );
  if( pDb->iDb==3 ){
    int *piOut = 0;
    sqlite3_stmt *pStmt = 0;
    SqlDatabase3 *p = (SqlDatabase3 *)pDb;

    if( pSql==0 ){
      rc = sqlite3_prepare(p->db, zSql, -1, &pStmt, 0);
    }else{
      pStmt = (sqlite3_stmt *)(pSql->pStmt);
    }

    if( zBind ){
      int i;
      va_list ap;

      va_start(ap, zBind);
      for(i=0; zBind[i] && rc==SQLITE_OK; i++){
        switch( zBind[i] ){
          case 'O': {
            piOut = va_arg(ap, int *);
            break;
          }

          case 'i': {
            int iVal = va_arg(ap, int);
            rc = sqlite3_bind_int(pStmt, i+1, iVal);
            break;
          };
          default:
            rc = -1;
            break;
        }
      }
      va_end(ap);
    }

    if( rc==SQLITE_OK ){
      while( SQLITE_ROW==sqlite3_step(pStmt) ){
        if( piOut ) *piOut = sqlite3_column_int(pStmt, 0);
      }
      rc = sqlite3_reset(pStmt);
      pNewStmt = pStmt;
    }else{
      sqlite3_finalize(pStmt);
    }
  }else{
    int *piOut = 0;
    sqlite4_stmt *pStmt = 0;
    SqlDatabase4 *p = (SqlDatabase4 *)pDb;

    if( pSql==0 ){
      rc = sqlite4_prepare(p->db, zSql, -1, &pStmt, 0);
    }else{
      pStmt = (sqlite4_stmt *)(pSql->pStmt);
    }

    if( zBind ){
      int i;
      va_list ap;

      va_start(ap, zBind);
      for(i=0; zBind[i] && rc==SQLITE4_OK; i++){
        switch( zBind[i] ){
          case 'O': {
            piOut = va_arg(ap, int *);
            break;
          }
          case 'i': {
            int iVal = va_arg(ap, int);
            rc = sqlite4_bind_int(pStmt, i+1, iVal);
            break;
          };
          default:
            rc = -1;
            break;
        }
      }
      va_end(ap);
    }

    if( rc==SQLITE4_OK ){
      while( SQLITE4_ROW==sqlite4_step(pStmt) ){
        if( piOut ) *piOut = sqlite4_column_int(pStmt, 0);
      }
      rc = sqlite4_reset(pStmt);
      pNewStmt = pStmt;
    }else{
      sqlite4_finalize(pStmt);
    }
  }

  if( pSql==0 && pNewStmt ){
    int nSql = strlen(zSql);
    pSql = sqlite4_malloc(0, sizeof(SqlStmt) + nSql + 1);
    memset(pSql, 0, sizeof(SqlStmt));
    pSql->zStmt = (char *)&pSql[1];
    memcpy(pSql->zStmt, zSql, nSql+1);
    pSql->pStmt = pNewStmt;
    pSql->pNext = pDb->pSqlStmt;
    pDb->pSqlStmt = pSql;
  }

  return rc;
}

static int do_int_insert_test(
  int iDb,
  const char *zCfg, 
  const char *zFile, 
  int nRow, 
  int nRowPerTrans
){
  int nMs = 0;
  SqlDatabase *db;
  int i;

  EXPLODE( open_database(iDb, zCfg, zFile, 1, &db) );
  EXPLODE( exec_sql(db, 
        "CREATE TABLE t1(k INTEGER PRIMARY KEY, v INTEGER)", 0
  ));

  testTimeInit();
  for(i=0; i<nRow; i++){
    if( (i % nRowPerTrans)==0 ){
      if( i!=0 ) EXPLODE( exec_sql(db, "COMMIT", 0) );
      EXPLODE( exec_sql(db, "BEGIN", 0) );
    }
    EXPLODE( exec_sql(db, 
          "INSERT INTO t1 VALUES(?+1, rint(?,0))", "ii", i, i
    ));
  }
  EXPLODE( exec_sql(db, "COMMIT", 0) );

  nMs = testTimeGet();

  close_database(db);
  printf("%.3f seconds\n", (double)nMs / 1000.0);
  return 0;
}

static int do_int_update_test(
  int iDb,
  const char *zCfg,
  const char *zFile,
  int nRow,
  int nRowPerTrans
){
  int nMs = 0;
  SqlDatabase *db;
  int i;
  int k = 0;
  int v = 0;
  int nTblRow = 0;

  EXPLODE( open_database(iDb, zCfg, zFile, 0, &db) );
  EXPLODE( exec_sql(db, "SELECT count(*) FROM t1", "O", &nTblRow) );

  testTimeInit();
  for(i=0; i<nRow; i++){
    if( (i % nRowPerTrans)==0 ){
      if( i!=0 ) EXPLODE( exec_sql(db, "COMMIT", 0) );
      EXPLODE( exec_sql(db, "BEGIN", 0) );
    }
    k = (testPrngValue(v+i) % nTblRow);
    v = (testPrngValue(k+i) % nTblRow);
    EXPLODE( exec_sql(db, "UPDATE t1 SET v = ? WHERE k = (?+1)", "ii", v, k));
  }
  EXPLODE( exec_sql(db, "COMMIT", 0) );

  nMs = testTimeGet();

  close_database(db);
  printf("%.3f seconds\n", (double)nMs / 1000.0);
  return 0;
}

static int get_int_test_args(
  int argc, char **argv,
  int *piDb,
  int *pnRow,
  int *pnRowPerTrans,
  const char **pzCfg,
  const char **pzFile
){
  struct Insert1Arg {
    const char *zArg;
    int nMin;
    int nMax;
  } aArg[] = {
    {"-db",           3,    4}, 
    {"-rows",         1,    10000000}, 
    {"-rowspertrans", 1,    10000000}, 
    {"-file",        -1,    -1}, 
    {"-config",      -1,    -1}, 
    {0,0,0}
  };
  int i;

  int iDb = 4;                    /* SQLite 3 or 4 */
  int nRow = 50000;               /* Total rows: 50000 */
  int nRowPerTrans = 10;          /* Total rows each transaction: 50000 */
  const char *zFile = 0;
  const char *zCfg = 0;

  for(i=0; i<argc; i++){
    int iSel;
    int rc;

    rc = testArgSelectX(aArg, "argument", sizeof(aArg[0]), argv[i], &iSel);
    if( rc!=0 ) return -1;
    if( i==argc-1 ){
      fprintf(stderr, "option %s requires an argument\n", aArg[iSel].zArg);
      return -1;
    }
    if( 0==strcmp("-config", aArg[iSel].zArg) ){
      zCfg = argv[++i];
    }else if( 0==strcmp("-file", aArg[iSel].zArg) ){
      zFile = argv[++i];
    }else{
      int iVal = atoi(argv[++i]);
      if( iVal<aArg[iSel].nMin || iVal>aArg[iSel].nMax ){
        fprintf(stderr, "option %s out of range (%d..%d)\n", 
            aArg[iSel].zArg, aArg[iSel].nMin, aArg[iSel].nMax 
        );
        return -1;
      }

      switch( iSel ){
        case 0: iDb = iVal;          break;
        case 1: nRow = iVal;         break;
        case 2: nRowPerTrans = iVal; break;
      }
    }
  }

  *piDb = iDb;
  *pnRow = nRow;
  *pnRowPerTrans = nRowPerTrans;
  *pzCfg = zCfg;
  *pzFile = zFile;
  return 0;
}

static int do_int_insert(int argc, char **argv){
  int iDb;
  int nRow;
  int nRowPerTrans;
  const char *zFile;
  const char *zCfg;
  int rc;

  rc = get_int_test_args(argc, argv, &iDb, &nRow, &nRowPerTrans, &zCfg, &zFile);
  if( rc!=0 ) return rc;

  printf("int_insert: db=%d rows=%d rowspertrans=%d ... ", 
      iDb, nRow, nRowPerTrans
  );
  fflush(stdout);
  do_int_insert_test(iDb, zCfg, zFile, nRow, nRowPerTrans);

  return 0;
}

static int do_int_update(int argc, char **argv){
  int iDb;
  int nRow;
  int nRowPerTrans;
  const char *zFile;
  const char *zCfg;
  int rc;

  rc = get_int_test_args(argc, argv, &iDb, &nRow, &nRowPerTrans, &zCfg, &zFile);
  if( rc!=0 ) return rc;

  printf("int_update: db=%d rows=%d rowspertrans=%d ... ", 
      iDb, nRow, nRowPerTrans
  );
  fflush(stdout);
  do_int_update_test(iDb, zCfg, zFile, nRow, nRowPerTrans);

  return 0;
}

int main(int argc, char **argv){
  struct SqltestArg {
    const char *zPrg;
    int (*xPrg)(int, char **);
  } aArg[] = { 
    {"select", do_select1},
    {"insert", do_insert1},
    {"int_insert", do_int_insert},
    {"int_update", do_int_update},
    {0, 0}
  };
  int iSel;
  int rc;

  if( argc<2 ){
    fprintf(stderr, "Usage: %s sub-program...\n", argv[0]);

Changes to main.mk

533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

threadtest: threadtest3$(EXE)
	./threadtest3$(EXE)

SQLSRC = $(TOP)/lsm-test/sqltest.c $(TOP)/lsm-test/lsmtest_util.c 
sqltest$(EXE): $(SQLSRC) libsqlite4.a
	$(TCCX) $(TOP)/lsm-test/sqltest.c \
        -o sqltest$(EXE) -lsqlite3 libsqlite4.a $(THREADLIB)

TEST_EXTENSION = $(SHPREFIX)testloadext.$(SO)
$(TEST_EXTENSION): $(TOP)/test/test_loadext.c
	$(MKSHLIB) $(TOP)/test/test_loadext.c -o $(TEST_EXTENSION)

extensiontest: testfixture$(EXE) $(TEST_EXTENSION)
	./testfixture$(EXE) $(TOP)/test/loadext.test







|







533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

threadtest: threadtest3$(EXE)
	./threadtest3$(EXE)

SQLSRC = $(TOP)/lsm-test/sqltest.c $(TOP)/lsm-test/lsmtest_util.c 
sqltest$(EXE): $(SQLSRC) libsqlite4.a
	$(TCCX) $(TOP)/lsm-test/sqltest.c \
        -o sqltest$(EXE) $(SQLITELIB) libsqlite4.a $(THREADLIB)

TEST_EXTENSION = $(SHPREFIX)testloadext.$(SO)
$(TEST_EXTENSION): $(TOP)/test/test_loadext.c
	$(MKSHLIB) $(TOP)/test/test_loadext.c -o $(TEST_EXTENSION)

extensiontest: testfixture$(EXE) $(TEST_EXTENSION)
	./testfixture$(EXE) $(TOP)/test/loadext.test