Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | For the xCreate/xConnect/xDisconnect/xDestroy methods of the SQLiteModule class, refactor out the common code into private methods. Changes to comments. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
9e6f8b4fca1ef61e53689044ff16ddb6 |
User & Date: | mistachkin 2013-07-05 01:31:12.898 |
Context
2013-07-05
| ||
02:10 | Adjustments to the #if directives related to the vtshim extension module. check-in: f680c43ce0 user: mistachkin tags: trunk | |
01:31 | For the xCreate/xConnect/xDisconnect/xDestroy methods of the SQLiteModule class, refactor out the common code into private methods. Changes to comments. check-in: 9e6f8b4fca user: mistachkin tags: trunk | |
2013-07-04
| ||
20:44 | Adjustments to the cleanup of several tests. check-in: a48ea4b8d9 user: mistachkin tags: trunk | |
Changes
Changes to System.Data.SQLite/SQLiteModule.cs.
︙ | ︙ | |||
5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 | xRollbackTo); return newModule; } /////////////////////////////////////////////////////////////////////// #region Static Error Handling Helper Methods /// <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"> | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 5563 5564 5565 5566 5567 5568 5569 5570 5571 5572 5573 5574 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 5594 5595 5596 5597 5598 5599 5600 5601 5602 5603 5604 5605 5606 5607 5608 5609 5610 5611 5612 5613 5614 5615 5616 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 5662 5663 5664 5665 5666 5667 5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680 5681 5682 5683 5684 5685 5686 5687 5688 5689 5690 | xRollbackTo); return newModule; } /////////////////////////////////////////////////////////////////////// /// <summary> /// Calls one of the virtual table initialization methods. /// </summary> /// <param name="create"> /// Non-zero to call the <see cref="ISQLiteManagedModule.Create" /> /// method; otherwise, the <see cref="ISQLiteManagedModule.Connect" /> /// method will be called. /// </param> /// <param name="pDb"> /// The native database connection handle. /// </param> /// <param name="pAux"> /// The original native pointer value that was provided to the /// sqlite3_create_module(), sqlite3_create_module_v2() or /// sqlite3_create_disposable_module() functions. /// </param> /// <param name="argc"> /// The number of arguments from the CREATE VIRTUAL TABLE statement. /// </param> /// <param name="argv"> /// The array of string arguments from the CREATE VIRTUAL TABLE /// statement. /// </param> /// <param name="pVtab"> /// Upon success, this parameter must be modified to point to the newly /// created native sqlite3_vtab derived structure. /// </param> /// <param name="pError"> /// Upon failure, this parameter must be modified to point to the error /// message, with the underlying memory having been obtained from the /// sqlite3_malloc() function. /// </param> /// <returns> /// A standard SQLite return code. /// </returns> private SQLiteErrorCode CreateOrConnect( bool create, IntPtr pDb, IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { try { string fileName = SQLiteString.StringFromUtf8IntPtr( UnsafeNativeMethods.sqlite3_db_filename(pDb, IntPtr.Zero)); using (SQLiteConnection connection = new SQLiteConnection( pDb, fileName, false)) { SQLiteVirtualTable table = null; string error = null; if ((create && Create(connection, pAux, SQLiteString.StringArrayFromUtf8SizeAndIntPtr(argc, argv), ref table, ref error) == SQLiteErrorCode.Ok) || (!create && Connect(connection, pAux, SQLiteString.StringArrayFromUtf8SizeAndIntPtr(argc, argv), ref table, ref error) == SQLiteErrorCode.Ok)) { if (table != null) { pVtab = TableToIntPtr(table); return SQLiteErrorCode.Ok; } else { pError = SQLiteString.Utf8IntPtrFromString( "no table was created"); } } else { pError = SQLiteString.Utf8IntPtrFromString(error); } } } catch (Exception e) /* NOTE: Must catch ALL. */ { pError = SQLiteString.Utf8IntPtrFromString(e.ToString()); } return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////////// /// <summary> /// Calls one of the virtual table finalization methods. /// </summary> /// <param name="destroy"> /// Non-zero to call the <see cref="ISQLiteManagedModule.Destroy" /> /// method; otherwise, the /// <see cref="ISQLiteManagedModule.Disconnect" /> method will be /// called. /// </param> /// <param name="pVtab"> /// The native pointer to the sqlite3_vtab derived structure. /// </param> /// <returns> /// A standard SQLite return code. /// </returns> private SQLiteErrorCode DestroyOrDisconnect( bool destroy, IntPtr pVtab ) { try { SQLiteVirtualTable table = TableFromIntPtr(pVtab); if (table != null) { if ((destroy && (Destroy(table) == SQLiteErrorCode.Ok)) || (!destroy && (Disconnect(table) == SQLiteErrorCode.Ok))) { if (tables != null) tables.Remove(pVtab); return SQLiteErrorCode.Ok; } } } catch (Exception e) /* NOTE: Must catch ALL. */ { // // NOTE: At this point, there is no way to report the error // condition back to the caller; therefore, use the // logging facility instead. // try { if (LogExceptions) { /* throw */ SQLiteLog.LogMessage(SQLiteBase.COR_E_EXCEPTION, String.Format(CultureInfo.CurrentCulture, "Caught exception in \"{0}\" method: {1}", destroy ? "xDestroy" : "xDisconnect", e)); } } catch { // do nothing. } } finally { FreeTable(pVtab); } return SQLiteErrorCode.Error; } /////////////////////////////////////////////////////////////////////// #region Static Error Handling Helper Methods /// <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"> |
︙ | ︙ | |||
6110 6111 6112 6113 6114 6115 6116 | #endregion /////////////////////////////////////////////////////////////////////// #region Function Lookup Methods /// <summary> /// Deterimines the key that should be used to identify and store the | > | | | 6269 6270 6271 6272 6273 6274 6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 | #endregion /////////////////////////////////////////////////////////////////////// #region Function Lookup Methods /// <summary> /// Deterimines the key that should be used to identify and store the /// <see cref="SQLiteFunction" /> object instance for the virtual table /// (i.e. to be returned via the /// <see cref="ISQLiteNativeModule.xFindFunction" /> method). /// </summary> /// <param name="argumentCount"> /// The number of arguments to the virtual table function. /// </param> /// <param name="name"> /// The name of the virtual table function. /// </param> |
︙ | ︙ | |||
6430 6431 6432 6433 6434 6435 6436 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { | < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 6590 6591 6592 6593 6594 6595 6596 6597 6598 6599 6600 6601 6602 6603 6604 6605 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { return CreateOrConnect( true, pDb, pAux, argc, argv, ref pVtab, ref pError); } /////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteNativeModule.xConnect" /> method. /// </summary> |
︙ | ︙ | |||
6505 6506 6507 6508 6509 6510 6511 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { | < < < < | < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < | 6629 6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 | IntPtr pAux, int argc, IntPtr argv, ref IntPtr pVtab, ref IntPtr pError ) { return CreateOrConnect( false, pDb, pAux, argc, argv, ref pVtab, ref pError); } /////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteNativeModule.xBestIndex" /> method. /// </summary> |
︙ | ︙ | |||
6604 6605 6606 6607 6608 6609 6610 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xDisconnect" /> method. /// </returns> private SQLiteErrorCode xDisconnect( IntPtr pVtab ) { | < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 6692 6693 6694 6695 6696 6697 6698 6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714 6715 6716 6717 6718 6719 6720 6721 6722 6723 6724 | /// <returns> /// See the <see cref="ISQLiteNativeModule.xDisconnect" /> method. /// </returns> private SQLiteErrorCode xDisconnect( IntPtr pVtab ) { return DestroyOrDisconnect(false, pVtab); } /////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteNativeModule.xDestroy" /> method. /// </summary> /// <param name="pVtab"> /// See the <see cref="ISQLiteNativeModule.xDestroy" /> method. /// </param> /// <returns> /// See the <see cref="ISQLiteNativeModule.xDestroy" /> method. /// </returns> private SQLiteErrorCode xDestroy( IntPtr pVtab ) { return DestroyOrDisconnect(true, pVtab); } /////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteNativeModule.xOpen" /> method. /// </summary> |
︙ | ︙ | |||
6944 6945 6946 6947 6948 6949 6950 | return Eof(cursor) ? 1 : 0; } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } | | | 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959 6960 6961 6962 | return Eof(cursor) ? 1 : 0; } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } return 1; /* NOTE: On any error, return "no more rows". */ } /////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteNativeModule.xColumn" /> method. /// </summary> |
︙ | ︙ | |||
7263 7264 7265 7266 7267 7268 7269 | } } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } | | | 7267 7268 7269 7270 7271 7272 7273 7274 7275 7276 7277 7278 7279 7280 7281 | } } catch (Exception e) /* NOTE: Must catch ALL. */ { SetTableError(pVtab, e.ToString()); } return 0; /* NOTE: On any error, return "no such function". */ } /////////////////////////////////////////////////////////////////////// /// <summary> /// See the <see cref="ISQLiteNativeModule.xRename" /> method. /// </summary> |
︙ | ︙ |