Update Reference Sources to .NET Framework 4.6.1
[mono.git] / mcs / class / referencesource / System.Data / Microsoft / SqlServer / Server / SmiEventSink.cs
1 //------------------------------------------------------------------------------
2 // <copyright file="SmiEventSink.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 // <owner current="true" primary="true">[....]</owner>
6 // <owner current="true" primary="false">[....]</owner>
7 //------------------------------------------------------------------------------
8
9 namespace Microsoft.SqlServer.Server {
10
11     using System;
12     using System.Data;
13     using System.Data.Sql;
14
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.
18
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). 
22
23     // Methods are commented with their corresponding TDS token
24
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 {
30
31         #region Active methods
32
33         // Called at end of stream whether errors or no
34         internal abstract void BatchCompleted( );
35
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) {
38             // Adding as of V200
39
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 );
44         }
45
46         // Called when the server database context changes (ENVCHANGE token)
47         internal abstract void DefaultDatabaseChanged( string databaseName );
48
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 );
51
52         // Called for new resultset starting (COLMETADATA token)
53         internal abstract void MetaDataAvailable( SmiQueryMetaData[] metaData, bool nextEventIsRow );
54
55
56         internal virtual void RowAvailable(SmiTypedGetterSetter rowData) {
57             // Adding as of V200
58
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 );
63         }
64
65         // Called when any statement completes on server (DONE token)
66         internal abstract void StatementCompleted( int rowsAffected );
67
68         // Called when a transaction is commited (ENVCHANGE token)
69         internal abstract void TransactionCommitted( long transactionId );
70
71         // Called when a transaction is commited (ENVCHANGE token)
72         internal abstract void TransactionDefected( long transactionId );
73
74         // Called when a transaction is commited (ENVCHANGE token)
75         internal abstract void TransactionEnlisted( long transactionId );
76
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 );
80
81         // Called when a transaction is rolled back (ENVCHANGE token)
82         internal abstract void TransactionRolledBack( long transactionId );
83
84         // Called when a transaction is started (ENVCHANGE token)
85         internal abstract void TransactionStarted( long transactionId );
86
87         #endregion
88
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 ) {
93             // Adding as of V3
94             // Obsoleting as of V200
95
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 );
100         }
101
102         // Called when a new row arrives (ROW token)
103         internal virtual void RowAvailable( ITypedGettersV3 rowData ) {
104             // Adding as of V3
105             // Obsoleting as of V200
106
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 );
111         }
112
113         #endregion
114
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.
120
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 );
125         }
126
127         #endregion
128         #endregion
129     }
130 }
131