1 //------------------------------------------------------------------------------
2 // <copyright file="SmiEventSink.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 // <owner current="true" primary="true">[....]</owner>
6 // <owner current="true" primary="false">[....]</owner>
7 //------------------------------------------------------------------------------
9 namespace Microsoft.SqlServer.Server {
13 using System.Data.Sql;
15 // SqlEventSink is implemented by calling code. In all methods that accept
16 // a SqlEventSink directly the sink must be able to handle multiple callbacks
17 // without control returning from the original call.
19 // Methods that do not accept SmiEventSync are (generally) ProcessEvent on
20 // the SmiEventStream methods returning a SmiEventStream and methods that
21 // are certain to never call to the server (most will, for in-proc back end).
23 // Methods are commented with their corresponding TDS token
25 // NOTE: Throwing from these methods will not usually produce the desired
26 // effect -- the managed to native boundary will eat any exceptions,
27 // and will cause a simple "Something bad happened" exception to be
28 // thrown in the native to managed boundary...
29 internal abstract class SmiEventSink {
31 #region Active methods
33 // Called at end of stream whether errors or no
34 internal abstract void BatchCompleted( );
36 // Called zero or one time when output parameters are available (errors could prevent event from occuring)
37 internal virtual void ParameterAvailable(SmiParameterMetaData metaData, SmiTypedGetterSetter paramValue, int ordinal) {
40 // Implement body with throw because there are only a couple of ways to get to this code:
41 // 1) Client is calling this method even though the server negotiated for V3- and hasn't implemented V200 yet.
42 // 2) Server didn't implement V200 on some interface, but negotiated V200+.
43 System.Data.Common.ADP.InternalError( System.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod );
46 // Called when the server database context changes (ENVCHANGE token)
47 internal abstract void DefaultDatabaseChanged( string databaseName );
49 // Called for messages and errors (ERROR and INFO tokens)
50 internal abstract void MessagePosted ( int number, byte state, byte errorClass, string server, string message, string procedure, int lineNumber );
52 // Called for new resultset starting (COLMETADATA token)
53 internal abstract void MetaDataAvailable( SmiQueryMetaData[] metaData, bool nextEventIsRow );
56 internal virtual void RowAvailable(SmiTypedGetterSetter rowData) {
59 // Implement body with throw because there are only a couple of ways to get to this code:
60 // 1) Client is calling this method even though the server negotiated for V3- and hasn't implemented V200 yet.
61 // 2) Server didn't implement V200 on some interface, but negotiated V200+.
62 System.Data.Common.ADP.InternalError( System.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod );
65 // Called when any statement completes on server (DONE token)
66 internal abstract void StatementCompleted( int rowsAffected );
68 // Called when a transaction is commited (ENVCHANGE token)
69 internal abstract void TransactionCommitted( long transactionId );
71 // Called when a transaction is commited (ENVCHANGE token)
72 internal abstract void TransactionDefected( long transactionId );
74 // Called when a transaction is commited (ENVCHANGE token)
75 internal abstract void TransactionEnlisted( long transactionId );
77 // Called when a transaction is forcibly ended in the server, not requested
78 // by the provider's batch (ENVCHANGE token)
79 internal abstract void TransactionEnded( long transactionId );
81 // Called when a transaction is rolled back (ENVCHANGE token)
82 internal abstract void TransactionRolledBack( long transactionId );
84 // Called when a transaction is started (ENVCHANGE token)
85 internal abstract void TransactionStarted( long transactionId );
89 #region OBSOLETE METHODS
90 #region OBSOLETED as of V200 but active in previous version
91 // Called zero or one time when output parameters are available (errors could prevent event from occuring)
92 internal virtual void ParametersAvailable( SmiParameterMetaData[] metaData, ITypedGettersV3 paramValues ) {
94 // Obsoleting as of V200
96 // Implement body with throw because there are only a couple of ways to get to this code:
97 // 1) Client is calling this method even though the server negotiated for V200+ and dropped support for V200-.
98 // 2) Server didn't implement V3- on some interface and negotiated V3-.
99 System.Data.Common.ADP.InternalError( System.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod );
102 // Called when a new row arrives (ROW token)
103 internal virtual void RowAvailable( ITypedGettersV3 rowData ) {
105 // Obsoleting as of V200
107 // Implement body with throw because there are only a couple of ways to get to this code:
108 // 1) Client is calling this method even though the server negotiated for V200+ and dropped support for V200-.
109 // 2) Server didn't implement V3- on some interface and negotiated V3-.
110 System.Data.Common.ADP.InternalError( System.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod );
115 #region OBSOLETED and never shipped (without ObsoleteAttribute)
116 // Called when a new row arrives (ROW token)
117 internal virtual void RowAvailable( ITypedGetters rowData ) {
118 // Obsoleting from SMI -- use end of dispose that takes an event sink instead.
119 // Intended to be removed (along with inheriting IDisposable) prior to RTM.
121 // Implement body with throw because there are only a couple of ways to get to this code:
122 // 1) Client is calling this method even though the server negotiated for V3+ and dropped support for V2-.
123 // 2) Server didn't implement V2- on some interface and negotiated V2-.
124 System.Data.Common.ADP.InternalError( System.Data.Common.ADP.InternalErrorCode.UnimplementedSMIMethod );