/ Check-in [03750a2a]
Login

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

Overview
Comment:Fix a problem with zeroblob() and CAST(...) expressions that could cause an assert() to fail. (CVS 4041)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 03750a2a6b5186689f7db6650c0a889429790b03
User & Date: danielk1977 2007-05-30 06:19:33
Context
2007-05-30
08:18
Add the start of the soak-test infrastructure. (CVS 4042) check-in: 5d0b247c user: danielk1977 tags: trunk
06:19
Fix a problem with zeroblob() and CAST(...) expressions that could cause an assert() to fail. (CVS 4041) check-in: 03750a2a user: danielk1977 tags: trunk
2007-05-29
12:11
Consider explicit collate clauses when matching WHERE constraints to indices. Fix for #2391. (CVS 4040) check-in: f9a95e92 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

   158    158   int sqlite3VdbeMemNulTerminate(Mem *pMem){
   159    159     if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){
   160    160       return SQLITE_OK;   /* Nothing to do */
   161    161     }
   162    162     if( pMem->flags & (MEM_Static|MEM_Ephem) ){
   163    163       return sqlite3VdbeMemMakeWriteable(pMem);
   164    164     }else{
   165         -    char *z = sqliteMalloc(pMem->n+2);
          165  +    char *z; 
          166  +    sqlite3VdbeMemExpandBlob(pMem);
          167  +    z = sqliteMalloc(pMem->n+2);
          168  +
   166    169       if( !z ) return SQLITE_NOMEM;
   167    170       memcpy(z, pMem->z, pMem->n);
   168    171       z[pMem->n] = 0;
   169    172       z[pMem->n+1] = 0;
   170    173       if( pMem->xDel ){
   171    174         pMem->xDel(pMem->z);
   172    175       }else{

Changes to test/zeroblob.test.

     9      9   #
    10     10   #***********************************************************************
    11     11   # This file implements regression tests for SQLite library.  The
    12     12   # focus of this file is testing of the zero-filled blob functionality
    13     13   # including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
    14     14   # and the built-in zeroblob() SQL function.
    15     15   #
    16         -# $Id: zeroblob.test,v 1.4 2007/05/23 06:31:39 drh Exp $
           16  +# $Id: zeroblob.test,v 1.5 2007/05/30 06:19:33 danielk1977 Exp $
    17     17   
    18     18   set testdir [file dirname $argv0]
    19     19   source $testdir/tester.tcl
    20     20   
    21     21   ifcapable !incrblob {
    22     22     finish_test
    23     23     return
................................................................................
   123    123   # Concatentation works with zeroblob
   124    124   #
   125    125   do_test zeroblob-4.1 {
   126    126     execsql {
   127    127       SELECT hex(zeroblob(2) || x'61')
   128    128     }
   129    129   } {000061}
          130  +
          131  +# Check various CAST(...) operations on zeroblob.
          132  +#
          133  +do_test zeroblob-5.1 {
          134  +  execsql {
          135  +    SELECT CAST (zeroblob(100) AS REAL);
          136  +  }
          137  +} {0.0}
          138  +do_test zeroblob-5.2 {
          139  +  execsql {
          140  +    SELECT CAST (zeroblob(100) AS INTEGER);
          141  +  }
          142  +} {0}
          143  +do_test zeroblob-5.3 {
          144  +  execsql {
          145  +    SELECT CAST (zeroblob(100) AS TEXT);
          146  +  }
          147  +} {{}}
          148  +do_test zeroblob-5.4 {
          149  +  execsql {
          150  +    SELECT CAST(zeroblob(100) AS BLOB);
          151  +  }
          152  +} [execsql {SELECT zeroblob(100)}]
   130    153     
   131    154   
   132    155   finish_test