/ Check-in [9d53cc88]
Login

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

Overview
Comment:Make sure the 3rd parameter to sqlite3_prepare() is honored. Ticket #1650. (CVS 3040)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:9d53cc880fd2aa3bd4b4a59f666b57b0b7864e8f
User & Date: drh 2006-01-30 22:35:44
Context
2006-01-30
22:48
Memory DB works with autovacuum. (CVS 3041) check-in: 34dff874 user: drh tags: trunk
22:35
Make sure the 3rd parameter to sqlite3_prepare() is honored. Ticket #1650. (CVS 3040) check-in: 9d53cc88 user: drh tags: trunk
22:12
Clarify that the nBytes parameter to sqlite3_prepare is always the number of bytes and never the number of characters. Ticket #1646. (CVS 3039) check-in: 8efc8c57 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/prepare.c.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
526
527
528
529
530
531
532






533

534
535
536
537
538
539
540
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.29 2006/01/25 22:50:38 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** Fill the InitData structure with an error message that indicates
................................................................................
      sqlite3SafetyOff(db);
      return SQLITE_LOCKED;
    }
  }
  
  memset(&sParse, 0, sizeof(sParse));
  sParse.db = db;






  sqlite3RunParser(&sParse, zSql, &zErrMsg);


  if( sqlite3MallocFailed() ){
    sParse.rc = SQLITE_NOMEM;
  }
  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
  if( sParse.checkSchema && !schemaIsValid(db) ){
    sParse.rc = SQLITE_SCHEMA;







|







 







>
>
>
>
>
>
|
>







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This file contains the implementation of the sqlite3_prepare()
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.30 2006/01/30 22:35:44 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>

/*
** Fill the InitData structure with an error message that indicates
................................................................................
      sqlite3SafetyOff(db);
      return SQLITE_LOCKED;
    }
  }
  
  memset(&sParse, 0, sizeof(sParse));
  sParse.db = db;
  if( nBytes>=0 && zSql[nBytes]!=0 ){
    char *zSqlCopy = sqlite3StrNDup(zSql, nBytes);
    sqlite3RunParser(&sParse, zSqlCopy, &zErrMsg);
    sParse.zTail += zSql - zSqlCopy;
    sqliteFree(zSqlCopy);
  }else{
    sqlite3RunParser(&sParse, zSql, &zErrMsg);
  }

  if( sqlite3MallocFailed() ){
    sParse.rc = SQLITE_NOMEM;
  }
  if( sParse.rc==SQLITE_DONE ) sParse.rc = SQLITE_OK;
  if( sParse.checkSchema && !schemaIsValid(db) ){
    sParse.rc = SQLITE_SCHEMA;

Changes to test/capi3.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
881
882
883
884
885
886
887

888
















889
#    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 callback-free C/C++ API.
#
# $Id: capi3.test,v 1.40 2006/01/23 21:37:32 drh Exp $
#

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

# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................
# Ticket #1219:  Make sure binding APIs can handle a NULL pointer.
#
do_test capi3-14.1 {
  set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
  lappend rc $msg
} {1 SQLITE_MISUSE}



















finish_test







|







 







>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
#    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 callback-free C/C++ API.
#
# $Id: capi3.test,v 1.41 2006/01/30 22:35:44 drh Exp $
#

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

# Return the UTF-16 representation of the supplied UTF-8 string $str.
# If $nt is true, append two 0x00 bytes as a nul terminator.
................................................................................
# Ticket #1219:  Make sure binding APIs can handle a NULL pointer.
#
do_test capi3-14.1 {
  set rc [catch {sqlite3_bind_text 0 1 hello 5} msg]
  lappend rc $msg
} {1 SQLITE_MISUSE}

# Ticket #1650:  Honor the nBytes parameter to sqlite3_prepare.
#
do_test capi3-15.1 {
  set sql {SELECT * FROM t2}
  set nbytes [string length $sql]
  append sql { WHERE a==1}
  set STMT [sqlite3_prepare $DB $sql $nbytes TAIL]
  sqlite3_step $STMT
  sqlite3_column_int $STMT 0
} {1}
do_test capi3-15.2 {
  sqlite3_step $STMT
  sqlite3_column_int $STMT 0
} {2}
do_test capi3-15.3 {
  sqlite3_finalize $STMT
} {SQLITE_OK}

finish_test