Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Batching support to SqlProgram #45

Open
thargy opened this issue Apr 5, 2017 · 0 comments
Open

Add Batching support to SqlProgram #45

thargy opened this issue Apr 5, 2017 · 0 comments
Assignees
Labels
enhancement A new feature, or an improvement to an existing feature
Milestone

Comments

@thargy
Copy link
Contributor

thargy commented Apr 5, 2017

SqlPrograms should support batching. This has particular complications when it comes to the parameterisation of scripts (see #42) and as such may require us to consider SQL Parsing to rewrite parameter names. Further, we need to consider how we handle and/or select connections (as a batch can only run on a single common connection), and, of course, transactions (see #43).

A batch will run multiple SqlProgram messages on a single connection, single call to the Database, and will probably make use of SQL Messaging (see #44) to delineate batched results.

@thargy thargy added this to the EnhancedData milestone Apr 5, 2017
@thargy thargy added the enhancement A new feature, or an improvement to an existing feature label Apr 5, 2017
billings7 added a commit that referenced this issue Apr 26, 2017
…complete.

#43 Minor work for passing a transaction to a batch. No external API currently, always passed as null.
billings7 added a commit that referenced this issue Apr 28, 2017
…he results back.

- Changed the signature of the AddExecute* methods, to return the result as an out parameter, and returning the SqlBatch instead.
  This helps with type parameter inference for the TOut for AddExecuteScalar, as otherwise you would have to specify ALL the types.
- Added SqlStringBuilder to help building SQL strings.
- Added basic end-to-end batching test. Upgraded the test database files.
billings7 added a commit that referenced this issue May 16, 2017
…ent, and some changes are needed around how errors are handled.

- Added handling of each command in a batch.
- Added support for ExecuteXmlReader to a batch.
- Added GetXmlReader() method to DbBatchDataReader and a SqlBatchDataTextReader class for simulating ExecuteXmlReader.
- Added SqlDataReader specific methods to SqlBatchDataReader.
- Changed some usages of SqlDataReader and SqlParameter to DbDataReader and DbParameter.
- Removed the state from Input<T>.
- Added a non-generic TaskCompletionSource class.
- Removed the generated SqlProgramGeneric* files from source control to reduce clutter
billings7 added a commit that referenced this issue May 16, 2017
…t in batches. The SQL generation is mostly complete, but the code still needs to handle errors raised correctly.

- A SqlBatch now stores a list of IBatchItem instead of just SqlBatchCommands. Both SqlBatch and SqlBatchCommand implement this interface.
- Heavily refactored the pre-processing to support nesting of batches and transactions, using the new IBatchItem interface.
- Added the ServerVersion to DatabaseSchema.
- The Connection class caches the DatabaseSchema for its connection string.
- Changed the common connection code to return Connection objects instead of just the connection string.
  This is used to get the ServerVersion from its DatabaseSchema, so better SQL can be generated if the version supports it.
billings7 added a commit that referenced this issue May 16, 2017
… individual commands.

- Added suppressErrors and exceptionHandler parameters to all the AddExecute methods and the SqlBatchCommand constructors.
- Removed the Create/AddTryCatch methods, and just added parameters to the Create/AddBatch methods to do the same.
- Rewrote the implementation of NonQuery to more accurately get the correct number of records affected.
- Also refactored the PerfTest to not use other test methods.
billings7 added a commit that referenced this issue May 17, 2017
…... CATCH in the SQL. Still need to implement error handling in the C#.

- Moved the code for wrapping SQL in TRY ... CATCH from the SqlBatch to extension methods on IBatchItem so that it can be used by SqlBatchCommand as well.
- The SQL now has a SELECT statement before each command to pause execution till the command is ready.
- Added supressErrors and exceptionHandler parameters to the generated AddExecute* generic overloads.
- Added missing generated AddExecuteXmlReader generic overloads.
- Added sproc to test LocalData.mdf database for raising an error, for testing error handling.
billings7 added a commit that referenced this issue May 18, 2017
- Executing a child batch now executes the root and waits for completion of the current batch.
- Fixed the NextResult[Async] methods in DbBatchDataReader so that they correctly return false after the final record set of the command.
- Any CmdSuccess flags set within a transaction are now set to 0 if the transaction is rolled back.
- Changed how the commands are enumerated in the execute method so the current batch and when its complete is know.
- Added a parameter to SqlBatchResult.GetResultAsync to indicate if the batch should begin executing or not if it isnt already.
billings7 added a commit that referenced this issue May 24, 2017
…tion support.

- Proper exceptions are now throw for errors
- Exceptions that occur in a batch get wrapped in either a SqlProgramExecutionException or a SqlBatchExecutionException depending on the location.
billings7 added a commit that referenced this issue Jun 8, 2017
…Batch.

Changed how the state of a DbBatchDataReader is handled. The previous way would of caused issues if the reader was closed/disposed before it had finished reading.
billings7 added a commit that referenced this issue Jun 8, 2017
- Made the synchronous versions of Execute* methods obsolete.
- Renamed SqlBatchParametersCollection to ParametersCollection as it is now not specific to batches.
- Removed the SqlProgramCommand class as it is no longer needed.
- Changed some usages of TimeSpan to Duration.
- Fixed SqlProgramParameter.CreateSqlParameter for table typed parameters. When not using CommandType.StoredProcedure,
  the TypeName must be specified for table type parameters.
- Fixed a potential deadlock when waiting on the semaphores for a batch. They are now sorted to make sure that
  they are always waited on in the same order. AsyncSemaphore can now be sorted to support this.
- Added LINQ extension methods for ordering by the elements themselves.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature, or an improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

2 participants