Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add the sqlite3_extended_errcode() interface. Change to return SQLITE_BUSY instead of SQLITE_ERROR when a COMMIT is attempted and one or more queries are still pending. (CVS 5850) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4c6a90a16627b1664bf7f15ab40b440b |
User & Date: | drh 2008-10-30 15:03:16.000 |
Context
2008-10-30
| ||
17:21 | Fix a crash that can follow a malloc failure in sqlite3ValueFromExpr(). Ticket #3468. (CVS 5851) (check-in: 0996783b1b user: danielk1977 tags: trunk) | |
15:03 | Add the sqlite3_extended_errcode() interface. Change to return SQLITE_BUSY instead of SQLITE_ERROR when a COMMIT is attempted and one or more queries are still pending. (CVS 5850) (check-in: 4c6a90a166 user: drh tags: trunk) | |
2008-10-29
| ||
07:01 | If a hot-journal file is detected but the application does not have the required read/write permissions, return SQLITE_CANTOPEN. Prior to this change, SQLITE_BUSY was returned. Ticket #3457. (CVS 5849) (check-in: dc5308c762 user: danielk1977 tags: trunk) | |
Changes
Changes to src/main.c.
︙ | |||
10 11 12 13 14 15 16 | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | - + | ** ************************************************************************* ** Main file for the SQLite library. The routines in this file ** implement the programmer interface to the library. Routines in ** other files are for internal use by SQLite and should not be ** accessed by users of the library. ** |
︙ | |||
1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 | 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 | + + + + + + + + + | if( db && !sqlite3SafetyCheckSickOrOk(db) ){ return SQLITE_MISUSE; } if( !db || db->mallocFailed ){ return SQLITE_NOMEM; } return db->errCode & db->errMask; } int sqlite3_extended_errcode(sqlite3 *db){ if( db && !sqlite3SafetyCheckSickOrOk(db) ){ return SQLITE_MISUSE; } if( !db || db->mallocFailed ){ return SQLITE_NOMEM; } return db->errCode; } /* ** Create a new collating function for database "db". The name is zName ** and the encoding is enc. */ static int createCollation( |
︙ |
Changes to src/sqlite.h.in.
︙ | |||
26 27 28 29 30 31 32 | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | - + | ** on how SQLite interfaces are suppose to operate. ** ** The name of this file under configuration management is "sqlite.h.in". ** The makefile makes some minor changes to this file (such as inserting ** the version number) and changes its name to "sqlite3.h" as ** part of the build process. ** |
︙ | |||
374 375 376 377 378 379 380 | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | - + + + | ** in *E an appropriate error message written into memory obtained ** from [sqlite3_malloc()]. ** ** {H12134} The [sqlite3_exec(D,S,C,A,E)] routine shall set the value of ** *E to NULL if E is not NULL and there are no errors. ** ** {H12137} The [sqlite3_exec(D,S,C,A,E)] function shall set the [error code] |
︙ | |||
2654 2655 2656 2657 2658 2659 2660 | 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 | - + + + + + + + + - + + - + + + | /* ** CAPI3REF: Error Codes And Messages {H12800} <S60200> ** ** The sqlite3_errcode() interface returns the numeric [result code] or ** [extended result code] for the most recent failed sqlite3_* API call ** associated with a [database connection]. If a prior API call failed ** but the most recent API call succeeded, the return value from |
︙ | |||
5761 5762 5763 5764 5765 5766 5767 5768 5769 5770 5771 5772 5773 5774 | 5773 5774 5775 5776 5777 5778 5779 5780 5781 5782 5783 5784 5785 5786 5787 | + | ** parameter is non-zero. ** ** {H17819} The [sqlite3_blob_open()] interface shall return [SQLITE_OK] on ** success and an appropriate [error code] on failure. ** ** {H17821} If an error occurs during evaluation of [sqlite3_blob_open(D,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_extended_errcode()], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error. ** ** {H17824} If any column in the row that a [sqlite3_blob] has open is ** changed by a separate [UPDATE] or [DELETE] statement or by ** an [ON CONFLICT] side effect, then the [sqlite3_blob] shall ** be marked as invalid. |
︙ | |||
5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884 5885 5886 5887 | 5887 5888 5889 5890 5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 | + | ** ** {H17865} If the requested read could not be completed, ** the [sqlite3_blob_read(P,Z,N,X)] interface shall return an ** appropriate [error code] or [extended error code]. ** ** {H17868} If an error occurs during evaluation of [sqlite3_blob_read(P,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_extended_errcode()], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error, where D is the ** [database connection] that was used to open the [BLOB handle] P. */ int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); /* |
︙ | |||
5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954 5955 5956 | 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968 5969 5970 5971 | + | ** ** {H17885} If the requested write could not be completed, ** the [sqlite3_blob_write(P,Z,N,X)] interface shall return an ** appropriate [error code] or [extended error code]. ** ** {H17888} If an error occurs during evaluation of [sqlite3_blob_write(D,...)] ** then subsequent calls to [sqlite3_errcode(D)], ** [sqlite3_extended_errcode()], ** [sqlite3_errmsg(D)], and [sqlite3_errmsg16(D)] shall return ** information appropriate for that error. */ int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); /* ** CAPI3REF: Virtual File System Objects {H11200} <S20100> |
︙ |
Changes to src/test1.c.
︙ | |||
9 10 11 12 13 14 15 | 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 all sorts of SQLite interfaces. This code ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** |
︙ | |||
113 114 115 116 117 118 119 | 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | } return TCL_OK; } const char *sqlite3TestErrorName(int rc){ const char *zName = 0; |
︙ | |||
3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 | 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 | + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + | } if( Tcl_GetIntFromObj(interp, objv[1], &ms) ){ return TCL_ERROR; } Tcl_SetObjResult(interp, Tcl_NewIntObj(sqlite3_sleep(ms))); return TCL_OK; } /* ** Usage: sqlite3_extended_errcode DB ** ** Return the string representation of the most recent sqlite3_* API ** error code. e.g. "SQLITE_ERROR". */ static int test_ex_errcode( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; int rc; if( objc!=2 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", Tcl_GetString(objv[0]), " DB", 0); return TCL_ERROR; } if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; rc = sqlite3_extended_errcode(db); Tcl_AppendResult(interp, (char *)t1ErrorName(rc), 0); return TCL_OK; } /* ** Usage: sqlite3_errcode DB ** ** Return the string representation of the most recent sqlite3_* API ** error code. e.g. "SQLITE_ERROR". */ static int test_errcode( void * clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[] ){ sqlite3 *db; int rc; |
︙ | |||
4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 | 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 | + | { "sqlite3_bind_blob", test_bind_blob ,0 }, { "sqlite3_bind_parameter_count", test_bind_parameter_count, 0}, { "sqlite3_bind_parameter_name", test_bind_parameter_name, 0}, { "sqlite3_bind_parameter_index", test_bind_parameter_index, 0}, { "sqlite3_clear_bindings", test_clear_bindings, 0}, { "sqlite3_sleep", test_sleep, 0}, { "sqlite3_errcode", test_errcode ,0 }, { "sqlite3_extended_errcode", test_ex_errcode ,0 }, { "sqlite3_errmsg", test_errmsg ,0 }, { "sqlite3_errmsg16", test_errmsg16 ,0 }, { "sqlite3_open", test_open ,0 }, { "sqlite3_open16", test_open16 ,0 }, { "sqlite3_complete16", test_complete16 ,0 }, { "sqlite3_prepare", test_prepare ,0 }, |
︙ |
Changes to src/vdbe.c.
︙ | |||
39 40 41 42 43 44 45 | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | - + | ** ** Various scripts scan this source file in order to generate HTML ** documentation, headers files, or other derived files. The formatting ** of the code in this file is, therefore, important. See other comments ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** |
︙ | |||
2407 2408 2409 2410 2411 2412 2413 | 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 | - + | /* If this instruction implements a COMMIT or ROLLBACK, other VMs are ** still running, and a transaction is active, return an error indicating ** that the other VMs must complete first. */ sqlite3SetString(&p->zErrMsg, db, "cannot %s transaction - " "SQL statements in progress", rollback ? "rollback" : "commit"); |
︙ |
Changes to test/capi3.test.
1 2 3 4 5 6 7 8 9 10 11 12 13 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | - + | # 2003 January 29 # # 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 callback-free C/C++ API. # |
︙ | |||
57 58 59 60 61 62 63 | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | - + + + + | sqlite3_get_autocommit $DB } 1 do_test capi3-1.1 { set STMT [sqlite3_prepare $DB {SELECT name FROM sqlite_master} -1 TAIL] sqlite3_finalize $STMT set TAIL } {} |
︙ | |||
88 89 90 91 92 93 94 | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | - + + + + | do_test capi3-1.7 { set sql {SELECT namex FROM sqlite_master} catch { set STMT [sqlite3_prepare $DB $sql -1 TAIL] } } {1} |
︙ | |||
114 115 116 117 118 119 120 | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | - + + + + | } {SELECT 10} do_test capi3-2.3 { set sql [utf16 {SELECT namex FROM sqlite_master}] catch { set STMT [sqlite3_prepare16 $DB $sql -1 TAIL] } } {1} |
︙ | |||
153 154 155 156 157 158 159 | 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | - + | do_test capi3-3.2 { sqlite3_close $db2 } {SQLITE_OK} do_test capi3-3.3 { catch { set db2 [sqlite3_open /bogus/path/test.db {}] } |
︙ | |||
820 821 822 823 824 825 826 | 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 | - + - + + + + | do_test capi3-11.1.1 { sqlite3_get_autocommit $DB } 0 do_test capi3-11.2 { set STMT [sqlite3_prepare $DB "SELECT func(b, a) FROM t1" -1 TAIL] sqlite3_step $STMT } {SQLITE_ROW} |
︙ |
Changes to test/capi3c.test.
︙ | |||
9 10 11 12 13 14 15 | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | - + | # #*********************************************************************** # 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. # |
︙ | |||
59 60 61 62 63 64 65 | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | - + + + + - + + + + | sqlite3_get_autocommit $DB } 1 do_test capi3c-1.1 { set STMT [sqlite3_prepare_v2 $DB {SELECT name FROM sqlite_master} -1 TAIL] sqlite3_finalize $STMT set TAIL } {} |
︙ | |||
104 105 106 107 108 109 110 | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | - + + + + | } {SELECT 10} do_test capi3c-2.3 { set sql [utf16 {SELECT namex FROM sqlite_master}] catch { set STMT [sqlite3_prepare16_v2 $DB $sql -1 TAIL] } } {1} |
︙ | |||
1227 1228 1229 1230 1231 1232 1233 | 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 | - + + + + | ifcapable progress { 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 { |
︙ |
Changes to test/misc7.test.
1 2 3 4 5 6 7 8 9 10 11 12 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | - + | # 2006 September 4 # # 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. # |
︙ | |||
393 394 395 396 397 398 399 | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | - + | sqlite3 db test.db catch {file attributes test.db-journal -permissions r--------} catch {file attributes test.db-journal -readonly 1} catchsql { SELECT count(*) FROM t3; } |
︙ |