/ Check-in [c2badb20]
Login

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

Overview
Comment:Improved test coverage for printf.c. (CVS 3780)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:c2badb208ff1207a1471410965947893b070ea50
User & Date: drh 2007-03-31 15:02:49
Context
2007-03-31
15:28
Increase test coverage by statically defining SQLITE_BIGENDIAN and related macros for ix86 platforms. Still a run-time test for other architectures. Need to add additional cases to cover other popular processors. (CVS 3781) check-in: 476e7c3f user: drh tags: trunk
15:02
Improved test coverage for printf.c. (CVS 3780) check-in: c2badb20 user: drh tags: trunk
13:00
The XFER optimization works if the target table lacks an integer primary key and is not empty as long as it has no indices. It always has and continues to work if the target table was empty. (CVS 3779) check-in: 2c62ffcb user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Show Whitespace Changes Patch

Changes to src/printf.c.

   817    817   /*
   818    818   ** Print into memory obtained from sqlite3_malloc()().  Omit the internal
   819    819   ** %-conversion extensions.
   820    820   */
   821    821   char *sqlite3_mprintf(const char *zFormat, ...){
   822    822     va_list ap;
   823    823     char *z;
   824         -  char zBase[SQLITE_PRINT_BUF_SIZE];
   825    824     va_start(ap, zFormat);
   826         -  z = base_vprintf(sqlite3_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
          825  +  z = sqlite3_vmprintf(zFormat, ap);
   827    826     va_end(ap);
   828    827     return z;
   829    828   }
   830    829   
   831    830   /*
   832    831   ** sqlite3_snprintf() works like snprintf() except that it ignores the
   833    832   ** current locale settings.  This is important for SQLite because we

Changes to src/test1.c.

     9      9   **    May you share freely, never taking more than you give.
    10     10   **
    11     11   *************************************************************************
    12     12   ** Code for testing all sorts of SQLite interfaces.  This code
    13     13   ** is not included in the SQLite library.  It is used for automated
    14     14   ** testing of the SQLite library.
    15     15   **
    16         -** $Id: test1.c,v 1.231 2007/03/27 14:44:51 drh Exp $
           16  +** $Id: test1.c,v 1.232 2007/03/31 15:02:49 drh Exp $
    17     17   */
    18     18   #include "sqliteInt.h"
    19     19   #include "tcl.h"
    20     20   #include "os.h"
    21     21   #include <stdlib.h>
    22     22   #include <string.h>
    23     23   
................................................................................
   929    929       if( Tcl_GetInt(interp, argv[i], &a[i-2]) ) return TCL_ERROR;
   930    930     }
   931    931     z = sqlite3_mprintf(argv[1], a[0], a[1], argc>4 ? argv[4] : NULL);
   932    932     Tcl_AppendResult(interp, z, 0);
   933    933     sqlite3_free(z);
   934    934     return TCL_OK;
   935    935   }
          936  +
          937  +/*
          938  +** Usage:  sqlite3_snprintf_str INTEGER FORMAT INTEGER INTEGER STRING
          939  +**
          940  +** Call mprintf with two integer arguments and one string argument
          941  +*/
          942  +static int sqlite3_snprintf_str(
          943  +  void *NotUsed,
          944  +  Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
          945  +  int argc,              /* Number of arguments */
          946  +  char **argv            /* Text of each argument */
          947  +){
          948  +  int a[3], i;
          949  +  int n;
          950  +  char *z;
          951  +  if( argc<5 || argc>6 ){
          952  +    Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
          953  +       " INT FORMAT INT INT ?STRING?\"", 0);
          954  +    return TCL_ERROR;
          955  +  }
          956  +  if( Tcl_GetInt(interp, argv[1], &n) ) return TCL_ERROR;
          957  +  if( n<0 ){
          958  +    Tcl_AppendResult(interp, "N must be non-negative", 0);
          959  +    return TCL_ERROR;
          960  +  }
          961  +  for(i=3; i<5; i++){
          962  +    if( Tcl_GetInt(interp, argv[i], &a[i-3]) ) return TCL_ERROR;
          963  +  }
          964  +  z = sqlite3_malloc( n+1 );
          965  +  sqlite3_snprintf(n, z, argv[2], a[0], a[1], argc>4 ? argv[5] : NULL);
          966  +  Tcl_AppendResult(interp, z, 0);
          967  +  sqlite3_free(z);
          968  +  return TCL_OK;
          969  +}
   936    970   
   937    971   /*
   938    972   ** Usage:  sqlite3_mprintf_double FORMAT INTEGER INTEGER DOUBLE
   939    973   **
   940    974   ** Call mprintf with two integer arguments and one double argument
   941    975   */
   942    976   static int sqlite3_mprintf_double(
................................................................................
  4082   4116     static struct {
  4083   4117        char *zName;
  4084   4118        Tcl_CmdProc *xProc;
  4085   4119     } aCmd[] = {
  4086   4120        { "sqlite3_mprintf_int",           (Tcl_CmdProc*)sqlite3_mprintf_int    },
  4087   4121        { "sqlite3_mprintf_int64",         (Tcl_CmdProc*)sqlite3_mprintf_int64  },
  4088   4122        { "sqlite3_mprintf_str",           (Tcl_CmdProc*)sqlite3_mprintf_str    },
         4123  +     { "sqlite3_snprintf_str",          (Tcl_CmdProc*)sqlite3_snprintf_str   },
  4089   4124        { "sqlite3_mprintf_stronly",       (Tcl_CmdProc*)sqlite3_mprintf_stronly},
  4090   4125        { "sqlite3_mprintf_double",        (Tcl_CmdProc*)sqlite3_mprintf_double },
  4091   4126        { "sqlite3_mprintf_scaled",        (Tcl_CmdProc*)sqlite3_mprintf_scaled },
  4092   4127        { "sqlite3_mprintf_hexdouble",   (Tcl_CmdProc*)sqlite3_mprintf_hexdouble},
  4093   4128        { "sqlite3_mprintf_z_test",        (Tcl_CmdProc*)test_mprintf_z        },
  4094   4129        { "sqlite3_mprintf_n_test",        (Tcl_CmdProc*)test_mprintf_n        },
  4095   4130        { "sqlite3_last_insert_rowid",     (Tcl_CmdProc*)test_last_rowid       },

Changes to test/printf.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing the sqlite_*_printf() interface.
    13     13   #
    14         -# $Id: printf.test,v 1.21 2006/03/19 13:00:25 drh Exp $
           14  +# $Id: printf.test,v 1.22 2007/03/31 15:02:50 drh Exp $
    15     15   
    16     16   set testdir [file dirname $argv0]
    17     17   source $testdir/tester.tcl
    18     18   
    19     19   set n 1
    20     20   foreach v {1 2 5 10 99 100 1000000 999999999 0 -1 -2 -5 -10 -99 -100 -9999999} {
    21     21     set v32 [expr {$v&0xffffffff}]
................................................................................
    89     89   } [format {%d %d A String: (%s)} 1 2 {This is the string}]
    90     90   do_test printf-3.5 {
    91     91     sqlite3_mprintf_str {%d %d A String: (%30s)} 1 2 {This is the string}
    92     92   } [format {%d %d A String: (%30s)} 1 2 {This is the string}]
    93     93   do_test printf-3.6 {
    94     94     sqlite3_mprintf_str {%d %d A String: (%-30s)} 1 2 {This is the string}
    95     95   } [format {%d %d A String: (%-30s)} 1 2 {This is the string}]
           96  +do_test snprintf-3.11 {
           97  +  sqlite3_snprintf_str 2 {x%d %d %s} 10 10 {This is the string}
           98  +} {x}
           99  +do_test snprintf-3.12 {
          100  +  sqlite3_snprintf_str 3 {x%d %d %s} 10 10 {This is the string}
          101  +} {x1}
          102  +do_test snprintf-3.13 {
          103  +  sqlite3_snprintf_str 4 {x%d %d %s} 10 10 {This is the string}
          104  +} {x10}
          105  +do_test snprintf-3.14 {
          106  +  sqlite3_snprintf_str 5 {x%d %d %s} 10 10 {This is the string}
          107  +} {x10 }
          108  +do_test snprintf-3.15 {
          109  +  sqlite3_snprintf_str 6 {x%d %d %s} 10 10 {This is the string}
          110  +} {x10 1}
          111  +do_test snprintf-3.16 {
          112  +  sqlite3_snprintf_str 7 {x%d %d %s} 10 10 {This is the string}
          113  +} {x10 10}
          114  +do_test snprintf-3.17 {
          115  +  sqlite3_snprintf_str 8 {x%d %d %s} 10 10 {This is the string}
          116  +} {x10 10 }
          117  +do_test snprintf-3.18 {
          118  +  sqlite3_snprintf_str 9 {x%d %d %s} 10 10 {This is the string}
          119  +} {x10 10 T}
          120  +do_test snprintf-3.19 {
          121  +  sqlite3_snprintf_str 100 {x%d %d %s} 10 10 {This is the string}
          122  +} {x10 10 This is the string}
    96    123   
    97    124   do_test printf-4.1 {
    98    125     sqlite3_mprintf_str {%d %d A quoted string: '%q'} 1 2 {Hi Y'all}
    99    126   } {1 2 A quoted string: 'Hi Y''all'}
   100    127   do_test printf-4.2 {
   101    128     sqlite3_mprintf_str {%d %d A NULL pointer in %%q: '%q'} 1 2
   102    129   } {1 2 A NULL pointer in %q: '(NULL)'}
................................................................................
   233    260   
   234    261   do_test printf-14.1 {
   235    262     sqlite3_mprintf_str {abc-%y-123} 0 0 {not used}
   236    263   } {abc-}
   237    264   do_test printf-14.2 {
   238    265     sqlite3_mprintf_n_test {xyzzy}
   239    266   } 5
          267  +do_test printf-14.3 {
          268  +  sqlite3_mprintf_str {abc-%T-123} 0 0 {not used}
          269  +} {abc-}
   240    270   
   241    271   
   242    272   finish_test

Changes to test/speed2.test.

     7      7   #    May you find forgiveness for yourself and forgive others.
     8      8   #    May you share freely, never taking more than you give.
     9      9   #
    10     10   #*************************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this script is measuring executing speed.
    13     13   #
    14         -# $Id: speed2.test,v 1.4 2007/03/28 18:04:10 drh Exp $
           14  +# $Id: speed2.test,v 1.5 2007/03/31 15:02:50 drh Exp $
    15     15   #
    16     16   
    17     17   set testdir [file dirname $argv0]
    18     18   source $testdir/tester.tcl
    19     19   
    20     20   # Set a uniform random seed
    21     21   expr srand(0)
................................................................................
    62     62   
    63     63   # Create a database schema.
    64     64   #
    65     65   do_test speed2-1.0 {
    66     66     execsql {
    67     67       PRAGMA page_size=1024;
    68     68       PRAGMA cache_size=8192;
    69         -    PRAGMA locking_mode=EXCLUSIVE;
           69  +--    PRAGMA locking_mode=EXCLUSIVE;
    70     70       CREATE TABLE t1(a INTEGER, b INTEGER, c TEXT);
    71     71       CREATE TABLE t2(a INTEGER, b INTEGER, c TEXT);
    72     72       CREATE INDEX i2a ON t2(a);
    73     73       CREATE INDEX i2b ON t2(b);
    74     74     }
    75     75     execsql {
    76     76       SELECT name FROM sqlite_master ORDER BY 1;