/ Check-in [49f25ddf]
Login

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

Overview
Comment:Avoid a segfault in sqlite3_bind_parameter_index when there are unnamed parameters. Ticket #918. (CVS 1977)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:49f25ddf8382d588e00bf927e2acae93e332e4d4
User & Date: drh 2004-09-24 12:48:13
Context
2004-09-24
12:50
Fix typo in ".help" output from the shell. Ticket #914. (CVS 1978) check-in: 1ee3a787 user: drh tags: trunk
12:48
Avoid a segfault in sqlite3_bind_parameter_index when there are unnamed parameters. Ticket #918. (CVS 1977) check-in: 49f25ddf user: drh tags: trunk
12:24
Simplification of the trigger code. (CVS 1976) check-in: 9fa904d9 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

591
592
593
594
595
596
597

598
599
600
601
602
603
  Vdbe *p = (Vdbe*)pStmt;
  int i;
  if( p==0 ){
    return 0;
  }
  createVarMap(p); 
  for(i=0; i<p->nVar; i++){

    if( strcmp(p->azVar[i],zName)==0 ){
      return i+1;
    }
  }
  return 0;
}







>
|





591
592
593
594
595
596
597
598
599
600
601
602
603
604
  Vdbe *p = (Vdbe*)pStmt;
  int i;
  if( p==0 ){
    return 0;
  }
  createVarMap(p); 
  for(i=0; i<p->nVar; i++){
    const char *z = p->azVar[i];
    if( z && strcmp(z,zName)==0 ){
      return i+1;
    }
  }
  return 0;
}

Changes to test/bind.test.

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
382
383
384
385
386
387
388








































389
#    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.19 2004/09/07 16:19:54 drh Exp $
#

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

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals
................................................................................
do_test bind-10.9 {
  sqlite3_finalize $VM
} SQLITE_OK
do_test bind-10.10 {
  execsql {SELECT * FROM t2}
} {1 999 1000 1001 {} {} 1 2 1 3 2 1}









































finish_test







|







 







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

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#    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.20 2004/09/24 12:48:13 drh Exp $
#

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

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals
................................................................................
do_test bind-10.9 {
  sqlite3_finalize $VM
} SQLITE_OK
do_test bind-10.10 {
  execsql {SELECT * FROM t2}
} {1 999 1000 1001 {} {} 1 2 1 3 2 1}

# Ticket #918
#
do_test bind-10.11 {
  catch {sqlite3_finalize $VM}
  set VM [
    sqlite3_prepare $DB {
      INSERT INTO t2(a,b,c,d,e,f) VALUES(:abc,?,?4,:pqr,:abc,?4)
    } -1 TAIL
  ]
  sqlite3_bind_parameter_count $VM
} 5
do_test bind-10.12 {
  sqlite3_bind_parameter_index $VM :xyz
} 0
do_test bind-10.13 {
  sqlite3_bind_parameter_index $VM {}
} 0
do_test bind-10.14 {
  sqlite3_bind_parameter_index $VM :pqr
} 5
do_test bind-10.15 {
  sqlite3_bind_parameter_index $VM ?4
} 4
do_test bind-10.16 {
  sqlite3_bind_parameter_name $VM 1
} :abc
do_test bind-10.16 {
  sqlite3_bind_parameter_name $VM 2
} {}
do_test bind-10.16 {
  sqlite3_bind_parameter_name $VM 3
} {}
do_test bind-10.16 {
  sqlite3_bind_parameter_name $VM 4
} {?4}
do_test bind-10.16 {
  sqlite3_bind_parameter_name $VM 5
} :pqr
catch {sqlite3_finalize $VM}

finish_test