/ Check-in [b01fda5f]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Fix for #2497. Set the database error code to the return value of sqlite3_step(). (CVS 4155)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b01fda5f50e40b6122faf169c44486bde7ffe16c
User & Date: danielk1977 2007-07-12 13:18:05
Context
2007-07-13
10:26
"extern" prototypes cause problems for the Digital Mars compiler. So remove them. Ticket #2502. (CVS 4156) check-in: f35fbf80 user: drh tags: trunk
2007-07-12
13:18
Fix for #2497. Set the database error code to the return value of sqlite3_step(). (CVS 4155) check-in: b01fda5f user: danielk1977 tags: trunk
2007-07-03
23:37
Fix compilation warnings shown when using strict GCC options for os_os2.c. (CVS 4154) check-in: 22277b7e user: pweilbacher tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/vdbeapi.c.

271
272
273
274
275
276
277

278
279
280
281
282
283
284
  sqlite3Error(p->db, rc, 0);
  p->rc = sqlite3ApiExit(p->db, p->rc);
end_of_step:
  assert( (rc&0xff)==rc );
  if( p->zSql && (rc&0xff)<SQLITE_ROW ){
    /* This behavior occurs if sqlite3_prepare_v2() was used to build
    ** the prepared statement.  Return error codes directly */

    return p->rc;
  }else{
    /* This is for legacy sqlite3_prepare() builds and when the code
    ** is SQLITE_ROW or SQLITE_DONE */
    return rc;
  }
}







>







271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
  sqlite3Error(p->db, rc, 0);
  p->rc = sqlite3ApiExit(p->db, p->rc);
end_of_step:
  assert( (rc&0xff)==rc );
  if( p->zSql && (rc&0xff)<SQLITE_ROW ){
    /* This behavior occurs if sqlite3_prepare_v2() was used to build
    ** the prepared statement.  Return error codes directly */
    sqlite3Error(p->db, p->rc, 0);
    return p->rc;
  }else{
    /* This is for legacy sqlite3_prepare() builds and when the code
    ** is SQLITE_ROW or SQLITE_DONE */
    return rc;
  }
}

Changes to test/capi3c.test.

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
1207
1208
1209
1210
1211
1212
1213
1214






























1215
#
#***********************************************************************
# This file implements regression tests for SQLite library.  
#
# This is a copy of the capi3.test file that has been adapted to
# test the new sqlite3_prepare_v2 interface.
#
# $Id: capi3c.test,v 1.7 2007/03/30 20:46:14 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.
................................................................................
do_test capi3c-20.3 {
  sqlite3_step $STMT
} SQLITE_DONE
do_test capi3c-20.4 {
  db2 close
  sqlite3_finalize $STMT
} SQLITE_OK































finish_test







|







 








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

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
....
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
#
#***********************************************************************
# This file implements regression tests for SQLite library.  
#
# This is a copy of the capi3.test file that has been adapted to
# test the new sqlite3_prepare_v2 interface.
#
# $Id: capi3c.test,v 1.8 2007/07/12 13:18:06 danielk1977 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.
................................................................................
do_test capi3c-20.3 {
  sqlite3_step $STMT
} SQLITE_DONE
do_test capi3c-20.4 {
  db2 close
  sqlite3_finalize $STMT
} SQLITE_OK

# Test that sqlite3_step() sets the database error code correctly.
# See ticket #2497.
#
do_test capi3c-21.1 {
  set STMT [sqlite3_prepare_v2 $DB {SELECT * FROM t3} -1 TAIL]
  db progress 5 "expr 1"
  sqlite3_step $STMT
} {SQLITE_INTERRUPT}
do_test capi3c-21.2 {
  sqlite3_errcode $DB
} {SQLITE_INTERRUPT}
do_test capi3c-21.3 {
  sqlite3_finalize $STMT
} {SQLITE_INTERRUPT}
do_test capi3c-21.4 {
  set STMT [sqlite3_prepare $DB {SELECT * FROM t3} -1 TAIL]
  db progress 5 "expr 1"
  sqlite3_step $STMT
} {SQLITE_ERROR}
do_test capi3c-21.5 {
  sqlite3_errcode $DB
} {SQLITE_ERROR}
do_test capi3c-21.6 {
  sqlite3_finalize $STMT
} {SQLITE_INTERRUPT}
do_test capi3c-21.7 {
  sqlite3_errcode $DB
} {SQLITE_INTERRUPT}


finish_test