Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Prevent the SetTableError virtual table helper method from throwing exceptions. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
04900b82e00cd2ee108ae944b3733168 |
User & Date: | mistachkin 2014-02-07 02:39:59.980 |
Context
2014-02-07
| ||
09:21 | Add TypeName_SQLiteProviderServices setting to the example config file. check-in: 14d909f5e7 user: mistachkin tags: trunk | |
02:39 | Prevent the SetTableError virtual table helper method from throwing exceptions. check-in: 04900b82e0 user: mistachkin tags: trunk | |
2014-02-06
| ||
19:58 | Update location of the 'version.html' file on the release procedures doc page. check-in: 1823a28959 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteModule.cs.
︙ | ︙ | |||
4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 | /// parameter to the various static error handling methods provided /// by the <see cref="SQLiteModule" /> class. /// </summary> private const bool DefaultLogErrors = true; /////////////////////////////////////////////////////////////////// /// <summary> /// This is the error message text used when the contained /// <see cref="SQLiteModule" /> object instance is not available /// for any reason. /// </summary> private const string ModuleNotAvailableErrorMessage = "native module implementation not available"; | > > > > > > > > > | 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 | /// parameter to the various static error handling methods provided /// by the <see cref="SQLiteModule" /> class. /// </summary> private const bool DefaultLogErrors = true; /////////////////////////////////////////////////////////////////// /// <summary> /// This is the value that is always used for the "logExceptions" /// parameter to the various static error handling methods provided /// by the <see cref="SQLiteModule" /> class. /// </summary> private const bool DefaultLogExceptions = true; /////////////////////////////////////////////////////////////////// /// <summary> /// This is the error message text used when the contained /// <see cref="SQLiteModule" /> object instance is not available /// for any reason. /// </summary> private const string ModuleNotAvailableErrorMessage = "native module implementation not available"; |
︙ | ︙ | |||
4659 4660 4661 4662 4663 4664 4665 | /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> private static SQLiteErrorCode ModuleNotAvailableTableError( IntPtr pVtab ) { SetTableError(null, pVtab, DefaultLogErrors, | | | 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 | /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> private static SQLiteErrorCode ModuleNotAvailableTableError( IntPtr pVtab ) { SetTableError(null, pVtab, DefaultLogErrors, DefaultLogExceptions, ModuleNotAvailableErrorMessage); return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////// /// <summary> |
︙ | ︙ | |||
4682 4683 4684 4685 4686 4687 4688 | /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> private static SQLiteErrorCode ModuleNotAvailableCursorError( IntPtr pCursor ) { SetCursorError(null, pCursor, DefaultLogErrors, | | | 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 | /// The value of <see cref="SQLiteErrorCode.Error" />. /// </returns> private static SQLiteErrorCode ModuleNotAvailableCursorError( IntPtr pCursor ) { SetCursorError(null, pCursor, DefaultLogErrors, DefaultLogExceptions, ModuleNotAvailableErrorMessage); return SQLiteErrorCode.Error; } #endregion /////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
6157 6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 | /// <param name="pVtab"> /// The native pointer to the sqlite3_vtab derived structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetTableError( SQLiteModule module, IntPtr pVtab, bool logErrors, string error ) { try { if (logErrors) { SQLiteLog.LogMessage(SQLiteErrorCode.Error, String.Format(CultureInfo.CurrentCulture, "Virtual table error: {0}", error)); /* throw */ } } catch { // do nothing. } if (pVtab == IntPtr.Zero) return false; int offset = 0; offset = SQLiteMarshal.NextOffsetOf(offset, IntPtr.Size, sizeof(int)); offset = SQLiteMarshal.NextOffsetOf(offset, sizeof(int), IntPtr.Size); | > > > > > > > > > > | | | | > > | | > > > > > | | | > > > > > > | | | | 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181 6182 6183 6184 6185 6186 6187 6188 6189 6190 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 | /// <param name="pVtab"> /// The native pointer to the sqlite3_vtab derived structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="logExceptions"> /// Non-zero if caught exceptions should be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetTableError( SQLiteModule module, IntPtr pVtab, bool logErrors, bool logExceptions, string error ) { try { if (logErrors) { SQLiteLog.LogMessage(SQLiteErrorCode.Error, String.Format(CultureInfo.CurrentCulture, "Virtual table error: {0}", error)); /* throw */ } } catch { // do nothing. } bool success = false; IntPtr pNewError = IntPtr.Zero; try { if (pVtab == IntPtr.Zero) return false; int offset = 0; offset = SQLiteMarshal.NextOffsetOf(offset, IntPtr.Size, sizeof(int)); offset = SQLiteMarshal.NextOffsetOf(offset, sizeof(int), IntPtr.Size); IntPtr pOldError = SQLiteMarshal.ReadIntPtr(pVtab, offset); if (pOldError != IntPtr.Zero) { SQLiteMemory.Free(pOldError); pOldError = IntPtr.Zero; SQLiteMarshal.WriteIntPtr(pVtab, offset, pOldError); } if (error == null) return true; pNewError = SQLiteString.Utf8IntPtrFromString(error); SQLiteMarshal.WriteIntPtr(pVtab, offset, pNewError); success = true; } catch (Exception e) /* NOTE: Must catch ALL. */ { try { if (logExceptions) { SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, String.Format(CultureInfo.CurrentCulture, "Caught exception in \"SetTableError\" method: {0}", e)); /* throw */ } } catch { // do nothing. } } finally { if (!success && (pNewError != IntPtr.Zero)) { SQLiteMemory.Free(pNewError); pNewError = IntPtr.Zero; } } return success; } /////////////////////////////////////////////////////////////////////// |
︙ | ︙ | |||
6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 6257 6258 6259 6260 6261 6262 6263 6264 6265 6266 6267 6268 6269 6270 6271 | /// The <see cref="SQLiteVirtualTable" /> object instance used to /// lookup the native pointer to the sqlite3_vtab derived structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetTableError( SQLiteModule module, SQLiteVirtualTable table, bool logErrors, string error ) { if (table == null) return false; IntPtr pVtab = table.NativeHandle; if (pVtab == IntPtr.Zero) return false; | > > > > > | > | 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 | /// The <see cref="SQLiteVirtualTable" /> object instance used to /// lookup the native pointer to the sqlite3_vtab derived structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="logExceptions"> /// Non-zero if caught exceptions should be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetTableError( SQLiteModule module, SQLiteVirtualTable table, bool logErrors, bool logExceptions, string error ) { if (table == null) return false; IntPtr pVtab = table.NativeHandle; if (pVtab == IntPtr.Zero) return false; return SetTableError( module, pVtab, logErrors, logExceptions, error); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Arranges for the specified error message to be placed into the /// zErrMsg field of a sqlite3_vtab derived structure, freeing the |
︙ | ︙ | |||
6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 6298 6299 6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 | /// used to get the native pointer to the sqlite3_vtab derived /// structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetCursorError( SQLiteModule module, IntPtr pCursor, bool logErrors, string error ) { if (pCursor == IntPtr.Zero) return false; IntPtr pVtab = TableFromCursor(module, pCursor); if (pVtab == IntPtr.Zero) return false; | > > > > > | > > > > > > | > | 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 6348 6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371 6372 6373 6374 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 | /// used to get the native pointer to the sqlite3_vtab derived /// structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="logExceptions"> /// Non-zero if caught exceptions should be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetCursorError( SQLiteModule module, IntPtr pCursor, bool logErrors, bool logExceptions, string error ) { if (pCursor == IntPtr.Zero) return false; IntPtr pVtab = TableFromCursor(module, pCursor); if (pVtab == IntPtr.Zero) return false; return SetTableError( module, pVtab, logErrors, logExceptions, error); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Arranges for the specified error message to be placed into the /// zErrMsg field of a sqlite3_vtab derived structure, freeing the /// existing error message, if any. /// </summary> /// <param name="module"> /// The <see cref="SQLiteModule" /> object instance to be used. /// </param> /// <param name="cursor"> /// The <see cref="SQLiteVirtualTableCursor" /> object instance used to /// lookup the native pointer to the sqlite3_vtab derived structure. /// </param> /// <param name="logErrors"> /// Non-zero if this error message should also be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="logExceptions"> /// Non-zero if caught exceptions should be logged using the /// <see cref="SQLiteLog" /> class. /// </param> /// <param name="error"> /// The error message. /// </param> /// <returns> /// Non-zero upon success. /// </returns> private static bool SetCursorError( SQLiteModule module, SQLiteVirtualTableCursor cursor, bool logErrors, bool logExceptions, string error ) { if (cursor == null) return false; IntPtr pCursor = cursor.NativeHandle; if (pCursor == IntPtr.Zero) return false; return SetCursorError( module, pCursor, logErrors, logExceptions, error); } #endregion #endregion /////////////////////////////////////////////////////////////////////// #region Protected Members |
︙ | ︙ | |||
6899 6900 6901 6902 6903 6904 6905 | /////////////////////////////////////////////////////////////////////// private bool logExceptions; /// <summary> /// Returns or sets a boolean value indicating whether exceptions /// caught in the /// <see cref="ISQLiteNativeModule.xDisconnect" /> method, | | > > | | 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 6963 6964 6965 6966 | /////////////////////////////////////////////////////////////////////// private bool logExceptions; /// <summary> /// Returns or sets a boolean value indicating whether exceptions /// caught in the /// <see cref="ISQLiteNativeModule.xDisconnect" /> method, /// the <see cref="ISQLiteNativeModule.xDestroy" /> method, /// the <see cref="SetTableError(IntPtr,string)" /> method, /// the <see cref="SetTableError(SQLiteVirtualTable,string)" /> method, /// and the <see cref="Dispose()" /> method should be logged using the /// <see cref="SQLiteLog" /> class. /// </summary> protected virtual bool LogExceptionsNoThrow { get { return logExceptions; } set { logExceptions = value; } } |
︙ | ︙ | |||
6932 6933 6934 6935 6936 6937 6938 | /// Non-zero upon success. /// </returns> protected virtual bool SetTableError( IntPtr pVtab, string error ) { | | > | 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 6996 6997 6998 6999 | /// Non-zero upon success. /// </returns> protected virtual bool SetTableError( IntPtr pVtab, string error ) { return SetTableError( this, pVtab, LogErrorsNoThrow, LogExceptionsNoThrow, error); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Arranges for the specified error message to be placed into the /// zErrMsg field of a sqlite3_vtab derived structure, freeing the |
︙ | ︙ | |||
6957 6958 6959 6960 6961 6962 6963 | /// Non-zero upon success. /// </returns> protected virtual bool SetTableError( SQLiteVirtualTable table, string error ) { | | > | 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 | /// Non-zero upon success. /// </returns> protected virtual bool SetTableError( SQLiteVirtualTable table, string error ) { return SetTableError( this, table, LogErrorsNoThrow, LogExceptionsNoThrow, error); } /////////////////////////////////////////////////////////////////////// /// <summary> /// Arranges for the specified error message to be placed into the /// zErrMsg field of a sqlite3_vtab derived structure, freeing the |
︙ | ︙ | |||
6982 6983 6984 6985 6986 6987 6988 | /// Non-zero upon success. /// </returns> protected virtual bool SetCursorError( SQLiteVirtualTableCursor cursor, string error ) { | | > | 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 | /// Non-zero upon success. /// </returns> protected virtual bool SetCursorError( SQLiteVirtualTableCursor cursor, string error ) { return SetCursorError( this, cursor, LogErrorsNoThrow, LogExceptionsNoThrow, error); } #endregion /////////////////////////////////////////////////////////////////////// #region Index Handling Helper Methods /// <summary> |
︙ | ︙ |