Changes between Version 34 and Version 35 of MapGuideRfc78
- Timestamp:
- 07/24/09 08:29:32 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
MapGuideRfc78
v34 v35 45 45 == Proposed Solution == 46 46 47 A new class of MgTransaction will be added to represent a transaction to be performed in a data store.47 A new class of !MgTransaction will be added to represent a transaction to be performed in a data store. 48 48 {{{ 49 49 /// \brief … … 76 76 Changes to Feature Service 77 77 78 ExecuteSqlQuery() and ExecuteSqlNonQuery() must use the same underlying connection on which the transaction started. So MgTransaction instance is passed in as parameters for both of these two methods. TheMgTransaction implementation can return the undelying connection.78 !ExecuteSqlQuery() and !ExecuteSqlNonQuery() must use the same underlying connection on which the transaction started. So !MgTransaction instance is passed in as parameters for both of these two methods. The !MgTransaction implementation can return the undelying connection. 79 79 80 The existing UpdateFeatures function will execute the standard commands in some other connection from the connection pool. If passing in true for useTransaction, it will use a different transaction other than the one started byBeginTransaction().80 The existing !UpdateFeatures function will execute the standard commands in some other connection from the connection pool. If passing in true for useTransaction, it will use a different transaction other than the one started by !BeginTransaction(). 81 81 82 So in order to be consistent with UpdateFeatures function, an overloaded version of UpdateFeatures function will be added taking a transaction object as well. It executes the standard commands within the same transaction explicityly started by BeginTransaction(). However this needs to be documented clearly to the users that if they are using the new APIs with the transaction object, they should stick to that and not mix in the oldUpdateFeatures() API.82 So in order to be consistent with !UpdateFeatures function, an overloaded version of !UpdateFeatures function will be added taking a transaction object as well. It executes the standard commands within the same transaction explicityly started by !BeginTransaction(). However this needs to be documented clearly to the users that if they are using the new APIs with the transaction object, they should stick to that and not mix in the old !UpdateFeatures() API. 83 83 84 84 {{{ … … 138 138 }}} 139 139 140 Note :141 a. If any exception is thrown within the sql statement execution, the new API won't rollback the transaction internally. Instead, it depends on the client application to rollback the transaction explicitly as illustrated in above codes. 142 b. If a provider doesn't support transaction, BeginTransaction() will throw anMgInvalidOperationException saying transaction is not supported.143 c. If passing in NULL for the parameter, ExecuteSqlQuery and ExecuteSqlNonQuery will work the same as before taking no transaction is started. For new version ofUpdateFeatures function, it will work the same as you pass in false for useTransaction.140 Notes: 141 * If any exception is thrown within the sql statement execution, the new API won't rollback the transaction internally. Instead, it depends on the client application to rollback the transaction explicitly as illustrated in above codes. 142 * If a provider doesn't support transaction, !BeginTransaction() will throw an !MgInvalidOperationException saying transaction is not supported. 143 * If passing in NULL for the parameter, !ExecuteSqlQuery and !ExecuteSqlNonQuery will work the same as before taking no transaction is started. For new version of !UpdateFeatures function, it will work the same as you pass in false for useTransaction. 144 144 145 Timeout configuration for MgTransaction145 Timeout configuration for !MgTransaction 146 146 147 147 As the transaction is a critical resource for database applications, a server-side transaction can be left open while the application is doing other things in between sql or even worse the application may fail or hang and the server would not know. So it needs to set a timeout for all transactions. If a transaction hasn't been committed or rollbacked within the timeout, the server will automatically rollback the transaction. If you call Commit() or Rollback() on the MgTransaction instance after timeout, an exception will be thrown reminding that the transaction has been timeout and reverted. … … 162 162 This new API is designed for sql statement execution. You have to use the API with !ExecuteSqlQuery() or !ExecuteSqlNonQuery() within the transaction. 163 163 164 If the user uses the new UpdateFeatures function taking the transaction object, they should stick to that and not mix in the oldUpdateFeatures() API.164 If the user uses the new !UpdateFeatures function taking the transaction object, they should stick to that and not mix in the old !UpdateFeatures() API. 165 165 166 166 == Test Plan ==