SQLite

Check-in [9d6057cd14]
Login

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

Overview
Comment:Make sure sqlite3_result_text can handle text strings with embedded '\000' characters. (CVS 2798)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9d6057cd141e7cdaf32ce68dea39e67c2c67a08d
User & Date: drh 2005-12-05 13:20:02.000
Context
2005-12-05
22:22
Update mailing list hyperlink on the support page. (CVS 2799) (check-in: 41a7aeeeb4 user: drh tags: trunk)
13:20
Make sure sqlite3_result_text can handle text strings with embedded '\000' characters. (CVS 2798) (check-in: 9d6057cd14 user: drh tags: trunk)
2005-12-02
02:44
Add a test to verify that binding text with embedded '\000' works. Also comment changes in os.h. (CVS 2797) (check-in: 31251a9098 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/test1.c.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the printf() interface to SQLite.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.169 2005/12/02 02:44:06 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>








|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
**    May you share freely, never taking more than you give.
**
*************************************************************************
** Code for testing the printf() interface to SQLite.  This code
** is not included in the SQLite library.  It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.170 2005/12/05 13:20:02 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
#include "os.h"
#include <stdlib.h>
#include <string.h>

369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
** Implementation of the x_coalesce() function.
** Return the first argument non-NULL argument.
*/
static void ifnullFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  int i;
  for(i=0; i<argc; i++){
    if( SQLITE_NULL!=sqlite3_value_type(argv[i]) ){
      sqlite3_result_text(context, sqlite3_value_text(argv[i]), -1,
          SQLITE_TRANSIENT);
      break;
    }
  }
}

/*
** A structure into which to accumulate text.







|
|







369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
** Implementation of the x_coalesce() function.
** Return the first argument non-NULL argument.
*/
static void ifnullFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
  int i;
  for(i=0; i<argc; i++){
    if( SQLITE_NULL!=sqlite3_value_type(argv[i]) ){
      sqlite3_result_text(context, sqlite3_value_text(argv[i]),
          sqlite3_value_bytes(argv[i]), SQLITE_TRANSIENT);
      break;
    }
  }
}

/*
** A structure into which to accumulate text.
Changes to test/bind.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 September 6
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.33 2005/12/02 02:44:06 drh Exp $
#

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

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 September 6
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.34 2005/12/05 13:20:03 drh Exp $
#

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

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals
512
513
514
515
516
517
518




519

520
521
  sqlite3_step $VM
  sqlite3_finalize $VM
  execsql {
    SELECT typeof(x), length(x), quote(x),
           length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3
  }
} {text 3 'abc' 10 X'6162630078797A007071'}







finish_test







>
>
>
>
|
>


512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
  sqlite3_step $VM
  sqlite3_finalize $VM
  execsql {
    SELECT typeof(x), length(x), quote(x),
           length(cast(x AS BLOB)), quote(cast(x AS BLOB)) FROM t3
  }
} {text 3 'abc' 10 X'6162630078797A007071'}
do_test bind-12.2 {
  sqlite3_create_function $DB
  execsql {
    SELECT quote(cast(x_coalesce(x) AS blob)) FROM t3
  }
} {X'6162630078797A007071'}

finish_test