SQLite

Check-in [03750a2a6b]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 03750a2a6b5186689f7db6650c0a889429790b03
User & Date: danielk1977 2007-05-30 06:19:33.000
Context
2007-05-30
08:18
Add the start of the soak-test infrastructure. (CVS 4042) (check-in: 5d0b247ca1 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: 03750a2a6b 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: f9a95e92df user: danielk1977 tags: trunk)
Changes
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/vdbemem.c.
158
159
160
161
162
163
164


165


166
167
168
169
170
171
172
158
159
160
161
162
163
164
165
166

167
168
169
170
171
172
173
174
175







+
+
-
+
+







int sqlite3VdbeMemNulTerminate(Mem *pMem){
  if( (pMem->flags & MEM_Term)!=0 || (pMem->flags & MEM_Str)==0 ){
    return SQLITE_OK;   /* Nothing to do */
  }
  if( pMem->flags & (MEM_Static|MEM_Ephem) ){
    return sqlite3VdbeMemMakeWriteable(pMem);
  }else{
    char *z; 
    sqlite3VdbeMemExpandBlob(pMem);
    char *z = sqliteMalloc(pMem->n+2);
    z = sqliteMalloc(pMem->n+2);

    if( !z ) return SQLITE_NOMEM;
    memcpy(z, pMem->z, pMem->n);
    z[pMem->n] = 0;
    z[pMem->n+1] = 0;
    if( pMem->xDel ){
      pMem->xDel(pMem->z);
    }else{
Changes to test/zeroblob.test.
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
9
10
11
12
13
14
15

16
17
18
19
20
21
22
23







-
+







#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this file is testing of the zero-filled blob functionality
# including the sqlite3_bind_zeroblob(), sqlite3_result_zeroblob(),
# and the built-in zeroblob() SQL function.
#
# $Id: zeroblob.test,v 1.4 2007/05/23 06:31:39 drh Exp $
# $Id: zeroblob.test,v 1.5 2007/05/30 06:19:33 danielk1977 Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

ifcapable !incrblob {
  finish_test
  return
123
124
125
126
127
128
129























130
131
132
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+



# Concatentation works with zeroblob
#
do_test zeroblob-4.1 {
  execsql {
    SELECT hex(zeroblob(2) || x'61')
  }
} {000061}

# Check various CAST(...) operations on zeroblob.
#
do_test zeroblob-5.1 {
  execsql {
    SELECT CAST (zeroblob(100) AS REAL);
  }
} {0.0}
do_test zeroblob-5.2 {
  execsql {
    SELECT CAST (zeroblob(100) AS INTEGER);
  }
} {0}
do_test zeroblob-5.3 {
  execsql {
    SELECT CAST (zeroblob(100) AS TEXT);
  }
} {{}}
do_test zeroblob-5.4 {
  execsql {
    SELECT CAST(zeroblob(100) AS BLOB);
  }
} [execsql {SELECT zeroblob(100)}]
  

finish_test