SQLite

Check-in [63bf73452d]
Login

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

Overview
Comment:Fix an assert() that may fail if sqlite3_step() is called on a statement after a previous call has already returned SQLITE_SCHEMA.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 63bf73452de5a9d03e625e1888444a5355063b74
User & Date: dan 2009-10-19 18:30:35.000
Context
2009-10-19
20:15
Fix an incorrect assert() in vdbeUnbind(). (check-in: 651c1efb99 user: drh tags: trunk)
18:30
Fix an assert() that may fail if sqlite3_step() is called on a statement after a previous call has already returned SQLITE_SCHEMA. (check-in: 63bf73452d user: dan tags: trunk)
18:11
Remove the sqlite3_reoptimize() API. The same functionality is now provided automatically to queries prepared using prepare_v2(). (check-in: 2c50b3d5aa user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/vdbeapi.c.
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
  /* Assert that malloc() has not failed */
  db = p->db;
  if( db->mallocFailed ){
    return SQLITE_NOMEM;
  }

  if( p->pc<=0 && p->expired ){
    if( ALWAYS(p->rc==SQLITE_OK) ){
      p->rc = SQLITE_SCHEMA;
    }
    rc = SQLITE_ERROR;
    goto end_of_step;
  }
  if( sqlite3SafetyOn(db) ){
    p->rc = SQLITE_MISUSE;







|







300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
  /* Assert that malloc() has not failed */
  db = p->db;
  if( db->mallocFailed ){
    return SQLITE_NOMEM;
  }

  if( p->pc<=0 && p->expired ){
    if( ALWAYS(p->rc==SQLITE_OK || p->rc==SQLITE_SCHEMA) ){
      p->rc = SQLITE_SCHEMA;
    }
    rc = SQLITE_ERROR;
    goto end_of_step;
  }
  if( sqlite3SafetyOn(db) ){
    p->rc = SQLITE_MISUSE;
Changes to test/schema.test.
359
360
361
362
363
364
365




















366
367

  # The schema cookie now has the same value as it did when SQL statement
  # $::STMT was prepared. So unless it has been expired, it would be
  # possible to run the "CREATE TABLE t4" statement and create a
  # duplicate table.
  list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
} {SQLITE_ERROR SQLITE_SCHEMA}





















finish_test







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


359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387

  # The schema cookie now has the same value as it did when SQL statement
  # $::STMT was prepared. So unless it has been expired, it would be
  # possible to run the "CREATE TABLE t4" statement and create a
  # duplicate table.
  list [sqlite3_step $::STMT] [sqlite3_finalize $::STMT]
} {SQLITE_ERROR SQLITE_SCHEMA}

do_test schema-13.1 {
  set S [sqlite3_prepare_v2 db "SELECT * FROM sqlite_master" -1 dummy]
  db function hello hello
  db function hello {}
  db auth auth
  proc auth {args} {
    if {[lindex $args 0] == "SQLITE_READ"} {return SQLITE_DENY}
    return SQLITE_OK
  }
  sqlite3_step $S
} {SQLITE_SCHEMA}

do_test schema-13.2 {
  sqlite3_step $S
} {SQLITE_SCHEMA}

do_test schema-13.3 {
  sqlite3_finalize $S
} {SQLITE_SCHEMA}

finish_test