/ Check-in [730ddb0b]
Login

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

Overview
Comment:Automatically cast BLOBs to strings prior to handing them over to functions like LIKE that want strings. Ticket #1605. (CVS 2928)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:730ddb0b74ed23c916dabd7ce893bd6bc55f3549
User & Date: drh 2006-01-12 19:42:41
Context
2006-01-12
20:28
Performance boost in sqlite3VdbeRecordCompare. (CVS 2929) check-in: 14c42307 user: drh tags: trunk
19:42
Automatically cast BLOBs to strings prior to handing them over to functions like LIKE that want strings. Ticket #1605. (CVS 2928) check-in: 730ddb0b user: drh tags: trunk
17:20
Cache the encoding value inside VdbeExec. (CVS 2927) check-in: 6d2a816e user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbemem.c.

747
748
749
750
751
752
753


754
755
756
757
758
759
760
const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
  if( !pVal ) return 0;
  assert( enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE || enc==SQLITE_UTF8);

  if( pVal->flags&MEM_Null ){
    return 0;
  }


  if( pVal->flags&MEM_Str ){
    sqlite3VdbeChangeEncoding(pVal, enc);
  }else if( !(pVal->flags&MEM_Blob) ){
    sqlite3VdbeMemStringify(pVal, enc);
  }
  assert(pVal->enc==enc || sqlite3ThreadDataReadOnly()->mallocFailed);
  return (const void *)(pVal->enc==enc ? (pVal->z) : 0);







>
>







747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
const void *sqlite3ValueText(sqlite3_value* pVal, u8 enc){
  if( !pVal ) return 0;
  assert( enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE || enc==SQLITE_UTF8);

  if( pVal->flags&MEM_Null ){
    return 0;
  }
  assert( (MEM_Blob>>3) == MEM_Str );
  pVal->flags |= (pVal->flags & MEM_Blob)>>3;
  if( pVal->flags&MEM_Str ){
    sqlite3VdbeChangeEncoding(pVal, enc);
  }else if( !(pVal->flags&MEM_Blob) ){
    sqlite3VdbeMemStringify(pVal, enc);
  }
  assert(pVal->enc==enc || sqlite3ThreadDataReadOnly()->mallocFailed);
  return (const void *)(pVal->enc==enc ? (pVal->z) : 0);

Changes to test/enc3.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
47
48
49
50
51
52
53














54
55
56
57
#
#***********************************************************************
# This file implements regression tests for SQLite library. 
#
# The focus of this file is testing of the proper handling of conversions
# to the native text representation.
#
# $Id: enc3.test,v 1.4 2004/11/14 21:56:31 drh Exp $

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

ifcapable {utf16} {
  do_test enc3-1.1 {
    execsql {
................................................................................
    }
  } {abcdef {}}
  do_test enc3-1.5 {
    execsql {
      SELECT quote(x) || ' ' || quote(y) FROM t1
    }
  } {{X'616263646566' NULL}}














}


finish_test







|







 







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




9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
#***********************************************************************
# This file implements regression tests for SQLite library. 
#
# The focus of this file is testing of the proper handling of conversions
# to the native text representation.
#
# $Id: enc3.test,v 1.5 2006/01/12 19:42:41 drh Exp $

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

ifcapable {utf16} {
  do_test enc3-1.1 {
    execsql {
................................................................................
    }
  } {abcdef {}}
  do_test enc3-1.5 {
    execsql {
      SELECT quote(x) || ' ' || quote(y) FROM t1
    }
  } {{X'616263646566' NULL}}
}
ifcapable {bloblit && utf16} {
  do_test enc3-2.1 {
    execsql {
      PRAGMA encoding
    }
  } {UTF-16le}
  do_test enc3-2.2 {
    execsql {
      CREATE TABLE t2(a);
      INSERT INTO t2 VALUES(x'61006200630064006500');
      SELECT CAST(a AS text) FROM t2 WHERE a LIKE 'abc%';
    }
  } {abcde}
}


finish_test