DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
ServerConnector.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2015 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 using System;
18 using System.Collections.Generic;
19 using System.Diagnostics;
20 
21 using Deveel.Data.Security;
22 using Deveel.Data.Sql;
23 using Deveel.Data.Sql.Objects;
25 using Deveel.Data.Sql.Triggers;
26 using Deveel.Data.Store;
28 using Deveel.Data.Types;
29 
30 namespace Deveel.Data.Protocol {
31  public abstract class ServerConnector : IServerConnector {
32  private bool autoCommit;
34  private bool ignoreIdentifiersCase;
35 
36  private Dictionary<int, QueryResult> resultMap;
37  private int uniqueResultId;
38 
39  protected ServerConnector(IDatabaseHandler databaseHandler) {
40  DatabaseHandler = databaseHandler;
41 
42  resultMap = new Dictionary<int, QueryResult>();
43  uniqueResultId = -1;
44  }
45 
47  Dispose(false);
48  }
49 
50  protected IDatabaseHandler DatabaseHandler { get; private set; }
51 
52  protected IDatabase Database { get; private set; }
53 
54  public void Dispose() {
55  GC.SuppressFinalize(this);
56  Dispose(true);
57  }
58 
59  protected virtual void Dispose(bool disposing) {
60  if (disposing) {
61  ClearResults();
62  }
63 
64  Database = null;
65  DatabaseHandler = null;
66 
67  ChangeState(ConnectorState.Disposed);
68  }
69 
70  public abstract ConnectionEndPoint LocalEndPoint { get; }
71 
72  public ConnectionEndPoint RemoteEndPoint { get; private set; }
73 
74  protected User User { get; private set; }
75 
76  protected IDictionary<string, object> Metadata { get; private set; }
77 
78  public ConnectorState CurrentState { get; private set; }
79 
80  private void AssertNotDisposed() {
81  if (CurrentState == ConnectorState.Disposed)
82  throw new ObjectDisposedException(GetType().AssemblyQualifiedName);
83  }
84 
85  private void AssertAuthenticated() {
86  if (CurrentState != ConnectorState.Authenticated)
87  throw new InvalidOperationException("The connector is not authenticated.");
88 
89  if (User == null)
90  throw new InvalidOperationException("The connector is authenticated but no user is set.");
91  }
92 
93  protected void SetAutoCommit(bool value) {
94  autoCommit = value;
95  }
96 
97  protected void SetParameterStyle(QueryParameterStyle parameterStyle) {
98  this.parameterStyle = parameterStyle;
99  }
100 
101  protected void SetIgnoreIdentifiersCase(bool value) {
102  ignoreIdentifiersCase = value;
103  }
104 
105  private void ClearResults() {
106  lock (resultMap) {
107  foreach (var result in resultMap.Values) {
108  if (result != null)
109  result.Dispose();
110  }
111 
112  resultMap.Clear();
113  }
114  }
115 
116  protected void ChangeState(ConnectorState newState) {
117  AssertNotDisposed();
118  CurrentState = newState;
119  }
120 
121  protected void OpenConnector(ConnectionEndPoint remoteEndPoint, string databaseName) {
122  try {
123  RemoteEndPoint = remoteEndPoint;
124  Database = DatabaseHandler.GetDatabase(databaseName);
125  if (Database == null)
126  throw new InvalidOperationException();
127 
128  OnConnectorOpen();
129  ChangeState(ConnectorState.Open);
130  } catch (Exception) {
131  // TODO: Log the error...
132  throw;
133  }
134  }
135 
136  protected virtual void OnConnectorOpen() {
137  }
138 
139  public abstract ConnectionEndPoint MakeEndPoint(IDictionary<string, object> properties);
140 
141  protected void CloseConnector() {
142  try {
143  OnCloseConnector();
144  } catch (Exception) {
145  // TODO: log the exception
146  } finally {
147  ChangeState(ConnectorState.Closed);
148  }
149  }
150 
151  protected virtual void OnCloseConnector() {
152  }
153 
154  protected virtual EncryptionData GetEncryptionData() {
155  return null;
156  }
157 
158  protected virtual bool Authenticate(string defaultSchema, string username, string password) {
159  if (CurrentState == ConnectorState.Authenticated)
160  throw new InvalidOperationException("Already authenticated.");
161 
162  // TODO: get the default schema from server configuration
163  if (String.IsNullOrEmpty(defaultSchema))
164  defaultSchema = "SA";
165 
166  // TODO: Log a debug information
167 
168  // TODO: Log an information about the logging user...
169 
170  try {
171  var user = Database.Authenticate(username, password);
172  if (user == null)
173  return false;
174 
175  if (!OnAuthenticated(user))
176  return false;
177 
178  User = user;
179 
180  // TODO: Accept more connection settings and store them here...
181  Metadata = new Dictionary<string, object> {
182  { "IgnoreIdentifiersCase", ignoreIdentifiersCase },
183  { "ParameterStyle", parameterStyle },
184  { "DefaultSchema", defaultSchema }
185  };
186 
187  ChangeState(ConnectorState.Authenticated);
188 
189  return true;
190  } catch (Exception) {
191  // TODO: throw server error
192  throw;
193  }
194  }
195 
196  protected virtual bool OnAuthenticated(User user) {
197  return true;
198  }
199 
200  //private IQueryContext OnAuthenticate(string defaultSchema, string username, string password) {
201  // var user = Database.Authenticate(username, password);
202 
203  // if (user == null)
204  // return null;
205 
206  // var session = Database.CreateUserSession(user);
207 
208  // // Put the connection in exclusive mode
209  // session.ExclusiveLock();
210 
211  // var context = new SessionQueryContext(session);
212 
213  // try {
214  // // By default, connections are auto-commit
215  // session.AutoCommit(true);
216 
217  // // Set the default schema for this connection if it exists
218  // if (context.SchemaExists(defaultSchema)) {
219  // context.CurrentSchema(defaultSchema);
220  // } else {
221  // // TODO: Log the warning..
222 
223  // // If we can't change to the schema then change to the APP schema
224  // session.CurrentSchema(Database.DatabaseContext.DefaultSchema());
225  // }
226  // } finally {
227  // try {
228  // session.Commit();
229  // } catch (TransactionException) {
230  // // TODO: Log the warning
231  // }
232  // }
233 
234  // return context;
235  //}
236 
237  private IQuery OpenQueryContext(long commitId) {
238  var transaction = Database.TransactionFactory.OpenTransactions.FindById((int)commitId);
239  if (transaction == null)
240  throw new InvalidOperationException();
241 
242  var session = new Session(transaction, User);
243  return session.CreateQuery();
244  }
245 
247  // TODO: make the isolation level configurable...
248  var transaction = Database.CreateTransaction(IsolationLevel.Serializable);
249  var session = new Session(transaction, User);
250  session.AutoCommit(true);
251  return session.CreateQuery();
252  }
253 
254  protected IQueryResponse[] ExecuteQuery(long commitId, string text, IEnumerable<QueryParameter> parameters) {
255  AssertAuthenticated();
256 
257  IQuery queryContext;
258  if (commitId > 0) {
259  queryContext = OpenQueryContext(commitId);
260  } else {
261  queryContext = CreateQueryContext();
262  }
263 
264  return ExecuteQuery(queryContext, text, parameters);
265  }
266 
267  protected virtual IQueryResponse[] ExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters) {
268  // TODO: Log a debug message..
269 
270  IQueryResponse[] response = null;
271 
272  try {
273  // Execute the Query (behaviour for this comes from super).
274  response = CoreExecuteQuery(context, text, parameters);
275 
276  // Return the result.
277  return response;
278  } finally {
279  // This always happens after tables are unlocked.
280  // Also guarenteed to happen even if something fails.
281 
282  // If we are in auto-commit mode then commit the Query here.
283  // Do we auto-commit?
284  if (context.AutoCommit()) {
285  // If an error occured then roll-back
286  if (response == null) {
287  // Rollback.
288  context.Rollback();
289  } else {
290  try {
291  // Otherwise commit.
292  context.Commit();
293  } catch (Exception) {
294  foreach (IQueryResponse queryResponse in response) {
295  // Dispose this response if the commit failed.
296  DisposeResult(queryResponse.ResultId);
297  }
298 
299  // And throw the SQL Exception
300  throw;
301  }
302  }
303  }
304  }
305  }
306 
307  protected IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable<QueryParameter> parameters) {
308  // Where Query result eventually resides.
309  int resultId = -1;
310 
311  // For each StreamableObject in the query object, translate it to a
312  // IRef object that presumably has been pre-pushed onto the server from
313  // the client.
314 
315  // Evaluate the sql Query.
316  var query = new SqlQuery(text);
317  if (parameters != null) {
318  // TODO: Download the Large-Objects and replace with a reference
319  }
320 
321  var stopwatch = new Stopwatch();
322  stopwatch.Start();
323 
324  var results = context.ExecuteQuery(query);
325  var responses = new IQueryResponse[results.Length];
326  int j = 0;
327 
328  foreach (var result in results) {
329  QueryResult queryResult;
330  try {
331  queryResult = new QueryResult(query, result);
332  resultId = AddResult(queryResult);
333  } catch (Exception) {
334  if (resultId != -1)
335  DisposeResult(resultId);
336 
337  throw;
338  }
339 
340  var taken = stopwatch.ElapsedMilliseconds;
341 
342  // Return the Query response
343  responses[j] = new QueryResponse(resultId, queryResult, (int)taken, "");
344 
345  j++;
346  }
347 
348  stopwatch.Stop();
349  return responses;
350  }
351 
352  private void DisposeResult(int resultId) {
353  // Remove this entry.
354  QueryResult result;
355  lock (resultMap) {
356  if (resultMap.TryGetValue(resultId, out result))
357  resultMap.Remove(resultId);
358  }
359 
360  if (result != null) {
361  result.Dispose();
362  } else {
363  // TODO: Log an error ...
364  }
365  }
366 
367  private int AddResult(QueryResult result) {
368  result.LockRoot();
369 
370  int resultId;
371 
372  lock (resultMap) {
373  resultId = ++uniqueResultId;
374  resultMap[resultId] = result;
375  }
376 
377  return resultId;
378  }
379 
380  protected int BeginTransaction() {
381  AssertAuthenticated();
382 
383  var transaction = Database.CreateTransaction(IsolationLevel.Serializable);
384  if (transaction == null)
385  throw new InvalidOperationException();
386 
387  return transaction.CommitId;
388  }
389 
391  return new ServerMessageProcessor(this);
392  }
393 
394  protected abstract IServerMessageEnvelope CreateEnvelope(IDictionary<string, object> metadata, IMessage message);
395 
396  IMessageEnvelope IConnector.CreateEnvelope(IDictionary<string, object> metadata, IMessage message) {
397  return CreateEnvelope(metadata, message);
398  }
399 
400 
401  public ILargeObjectChannel CreateObjectChannel(long objectId) {
402  throw new NotImplementedException();
403  }
404 
405  public ITriggerChannel CreateTriggerChannel(string triggerName, string objectName, TriggerEventType eventType) {
406  throw new NotImplementedException();
407  }
408 
409  protected virtual IMessage GetMessage(IMessageEnvelope envelope) {
410  if (envelope == null)
411  return null;
412 
413  // TODO: handle errors? it's not supposed the client to send errors to the server ...
414 
415  return envelope.Message;
416  }
417 
418  protected void CommitTransaction(int commitId) {
419  AssertNotDisposed();
420 
421  var transaction = Database.TransactionFactory.OpenTransactions.FindById(commitId);
422  if (transaction == null)
423  throw new InvalidOperationException();
424 
425  using (var session = new Session(transaction, User)) {
426  session.Commit();
427  }
428  }
429 
430  protected void RollbackTransaction(int commitId) {
431  AssertNotDisposed();
432 
433  var transaction = Database.TransactionFactory.OpenTransactions.FindById(commitId);
434  if (transaction == null)
435  throw new InvalidOperationException();
436 
437  using (var session = new Session(transaction, User)) {
438  session.Rollback();
439  }
440  }
441 
442  protected QueryResultPart GetResultPart(int resultId, int startRow, int countRows) {
443  AssertNotDisposed();
444 
445  var table = GetResult(resultId);
446  if (table == null)
447  throw new InvalidOperationException();
448 
449  int rowEnd = startRow + countRows;
450 
451  if (startRow < 0 || startRow >= table.RowCount || rowEnd > table.RowCount) {
452  throw new InvalidOperationException("Result part out of range.");
453  }
454 
455  try {
456  int colCount = table.ColumnCount;
457  var block = new QueryResultPart(colCount);
458  for (int r = startRow; r < rowEnd; ++r) {
459  var row = new ISqlObject[colCount];
460  var sizes = new int[colCount];
461 
462  for (int c = 0; c < colCount; ++c) {
463  var value = table.GetValue(r, c);
464 
465  ISqlObject clientOb = null;
466  if (value.Value is IObjectRef) {
467  var reference = (IObjectRef)value.Value;
468  // TODO: Make a protocol placeholder for the large object ref
469  } else {
470  clientOb = value.Value;
471  }
472 
473  row[c] = clientOb;
474  sizes[c] = value.Size;
475  }
476 
477  block.AddRow(new QueryResultRow(row, sizes));
478  }
479  return block;
480  } catch (Exception) {
481  // TODO: Log a warning ...
482  throw;
483  }
484  }
485 
486  protected QueryResult GetResult(int resultId) {
487  lock (resultMap) {
488  QueryResult result;
489  if (!resultMap.TryGetValue(resultId, out result))
490  return null;
491 
492  return result;
493  }
494  }
495 
496  private ObjectId CreateLargeObject(long objectLength) {
497  throw new NotImplementedException();
498  }
499 
500  #region QueryResponse
501 
503  public QueryResponse(int resultId, QueryResult queryResult, int millis, string warnings) {
504  ResultId = resultId;
505  QueryResult = queryResult;
506  QueryTimeMillis = millis;
507  Warnings = warnings;
508  }
509 
510  public int ResultId { get; private set; }
511 
512  public QueryResult QueryResult { get; set; }
513 
514  public int QueryTimeMillis { get; private set; }
515 
516  public int RowCount {
517  get { return QueryResult.RowCount; }
518  }
519 
520  public int ColumnCount {
521  get { return QueryResult.ColumnCount; }
522  }
523 
524  public QueryResultColumn GetColumn(int column) {
525  return QueryResult.GetColumn(column);
526  }
527 
528  public string Warnings { get; private set; }
529  }
530 
531  #endregion
532 
533  #region ServerMessageProcessor
534 
536  private readonly ServerConnector connector;
537 
539  this.connector = connector;
540  }
541 
542  private IMessageEnvelope CreateErrorResponse(IMessageEnvelope sourceMessage, string message) {
543  return CreateErrorResponse(sourceMessage, new ProtocolException(message));
544  }
545 
546  private IMessageEnvelope CreateErrorResponse(IMessageEnvelope sourceMessage, Exception error) {
547  IDictionary<string, object> metadata = null;
548  if (sourceMessage != null)
549  metadata = sourceMessage.Metadata;
550 
551  return CreateErrorResponse(metadata, error);
552  }
553 
554  private IMessageEnvelope CreateErrorResponse(IDictionary<string, object> metadata, Exception error) {
555  var envelope = connector.CreateEnvelope(metadata, new AcknowledgeResponse(false));
556  envelope.SetError(error);
557  return envelope;
558  }
559 
560  private IMessageEnvelope ProcessAuthenticate(IDictionary<string, object> metadata, AuthenticateRequest request) {
561  try {
562  if (!connector.Authenticate(request.DefaultSchema, request.UserName, request.Password)) {
563  var response = connector.CreateEnvelope(metadata, new AuthenticateResponse(false, -1));
564  // TODO: make the specialized exception ...
565  response.SetError(new Exception("Unable to authenticate."));
566  return response;
567  }
568 
569  connector.ChangeState(ConnectorState.Authenticated);
570 
571  // TODO: Get the UNIX epoch here?
572  return connector.CreateEnvelope(metadata, new AuthenticateResponse(true, DateTime.UtcNow.Ticks));
573  } catch (Exception ex) {
574  return CreateErrorResponse(metadata, ex);
575  }
576  }
577 
579  var metadata = envelope.Metadata;
580  var message = connector.GetMessage(envelope);
581  if (message == null)
582  return CreateErrorResponse(metadata, new Exception("No message found in the envelope."));
583 
584  if (message is ConnectRequest)
585  return ProcessConnect(metadata, (ConnectRequest)message);
586 
587  if (message is AuthenticateRequest)
588  return ProcessAuthenticate(metadata, (AuthenticateRequest)message);
589 
590  if (message is QueryExecuteRequest)
591  return ProcessQuery(metadata, (QueryExecuteRequest)message);
592  if (message is QueryResultPartRequest)
593  return ProcessQueryPart(metadata, (QueryResultPartRequest)message);
594  if (message is DisposeResultRequest)
595  return ProcessDisposeResult(metadata, (DisposeResultRequest)message);
596 
597  if (message is LargeObjectCreateRequest)
598  return ProcessCreateLargeObject(metadata, (LargeObjectCreateRequest)message);
599 
600  if (message is BeginRequest)
601  return ProcessBegin(metadata);
602  if (message is CommitRequest)
603  return ProcessCommit(metadata, (CommitRequest)message);
604  if (message is RollbackRequest)
605  return ProcessRollback(metadata, (RollbackRequest)message);
606 
607  if (message is CloseRequest)
608  return ProcessClose(metadata);
609 
610  return CreateErrorResponse(envelope, "Message not supported");
611  }
612 
613  private IMessageEnvelope ProcessConnect(IDictionary<string, object> metadata, ConnectRequest request) {
614  Exception error = null;
615  ConnectResponse response;
616 
617  try {
618  connector.OpenConnector(request.RemoteEndPoint, request.DatabaseName);
619  if (request.AutoCommit)
620  connector.SetAutoCommit(request.AutoCommit);
621 
622  connector.SetIgnoreIdentifiersCase(request.IgnoreIdentifiersCase);
623  connector.SetParameterStyle(request.ParameterStyle);
624 
625  var encryptionData = connector.GetEncryptionData();
626 
627  var serverVersion = connector.Database.Version.ToString(2);
628  response = new ConnectResponse(true, serverVersion, encryptionData != null, encryptionData);
629  } catch (Exception ex) {
630  // TODO: Log the error ...
631  error = ex;
632  response = new ConnectResponse(false, null);
633  }
634 
635  var envelope = connector.CreateEnvelope(metadata, response);
636  if (error != null)
637  envelope.SetError(error);
638 
639  return connector.CreateEnvelope(metadata, response);
640  }
641 
642  private IMessageEnvelope ProcessClose(IDictionary<string, object> metadata) {
643  try {
644  connector.AssertNotDisposed();
645  connector.AssertAuthenticated();
646 
647  connector.CloseConnector();
648  return connector.CreateEnvelope(metadata, new AcknowledgeResponse(true));
649  } catch (Exception ex) {
650  // TODO: Log the error ...
651  return CreateErrorResponse(metadata, ex);
652  }
653  }
654 
655  private IMessageEnvelope ProcessQuery(IDictionary<string, object> metadata, QueryExecuteRequest request) {
656  try {
657  connector.AssertNotDisposed();
658  connector.AssertAuthenticated();
659 
660  // TODO: use the timeout ...
661  var queryResonse = connector.ExecuteQuery(request.CommitId, request.Query.Text, request.Query.Parameters);
662  return connector.CreateEnvelope(metadata, new QueryExecuteResponse(queryResonse));
663  } catch (Exception ex) {
664  // TODO: Log the error ...
665  return CreateErrorResponse(metadata, ex);
666  }
667  }
668 
669  private IMessageEnvelope ProcessQueryPart(IDictionary<string, object> metadata, QueryResultPartRequest request) {
670  try {
671  connector.AssertNotDisposed();
672  connector.AssertAuthenticated();
673 
674  var part = connector.GetResultPart(request.ResultId, request.RowIndex, request.Count);
675  return connector.CreateEnvelope(metadata, new QueryResultPartResponse(request.ResultId, part));
676  } catch (Exception ex) {
677  // TODO: Log the error ...
678  return CreateErrorResponse(metadata, ex);
679  }
680  }
681 
682  private IMessageEnvelope ProcessDisposeResult(IDictionary<string, object> metadata, DisposeResultRequest request) {
683  try {
684  connector.AssertNotDisposed();
685  connector.AssertAuthenticated();
686 
687  connector.DisposeResult(request.ResultId);
688  return connector.CreateEnvelope(metadata, new AcknowledgeResponse(true));
689  } catch (Exception ex) {
690  // TODO: Log the error ...
691  return CreateErrorResponse(metadata, ex);
692  }
693  }
694 
695  private IMessageEnvelope ProcessCreateLargeObject(IDictionary<string, object> metadata,
696  LargeObjectCreateRequest request) {
697  try {
698  connector.AssertNotDisposed();
699  connector.AssertAuthenticated();
700 
701  var objRef = connector.CreateLargeObject(request.ObjectLength);
702  return connector.CreateEnvelope(metadata, new LargeObjectCreateResponse(request.ObjectLength, objRef));
703  } catch (Exception ex) {
704  // TODO: Log the error ...
705  return CreateErrorResponse(metadata, ex);
706  }
707  }
708 
709  private IMessageEnvelope ProcessBegin(IDictionary<string, object> metadata) {
710  try {
711  connector.AssertNotDisposed();
712  connector.AssertAuthenticated();
713 
714  var id = connector.BeginTransaction();
715  return connector.CreateEnvelope(metadata, new BeginResponse(id));
716  } catch (Exception ex) {
717  // TODO: Log the error ...
718  return CreateErrorResponse(metadata, ex);
719  }
720  }
721 
722  private IMessageEnvelope ProcessCommit(IDictionary<string, object> metadata, CommitRequest request) {
723  try {
724  connector.AssertNotDisposed();
725  connector.AssertAuthenticated();
726 
727  connector.CommitTransaction(request.TransactionId);
728  return connector.CreateEnvelope(metadata, new AcknowledgeResponse(true));
729  } catch (Exception ex) {
730  // TODO: Log the error ...
731  return CreateErrorResponse(metadata, ex);
732  }
733  }
734 
735  private IMessageEnvelope ProcessRollback(IDictionary<string, object> metadata, RollbackRequest request) {
736  try {
737  connector.AssertNotDisposed();
738  connector.AssertAuthenticated();
739 
740  connector.RollbackTransaction(request.TransactionId);
741  return connector.CreateEnvelope(metadata, new AcknowledgeResponse(true));
742  } catch (Exception ex) {
743  // TODO: Log the error ...
744  return CreateErrorResponse(metadata, ex);
745  }
746  }
747  }
748 
749  #endregion
750  }
751 }
IMessageProcessor CreateProcessor()
IMessageEnvelope CreateErrorResponse(IDictionary< string, object > metadata, Exception error)
IMessageEnvelope ProcessQueryPart(IDictionary< string, object > metadata, QueryResultPartRequest request)
int ColumnCount
Returns the column count.
Definition: QueryResult.cs:98
A long string in the system.
IMessageEnvelope ProcessCommit(IDictionary< string, object > metadata, CommitRequest request)
TriggerEventType
The different types of high layer trigger events.
Dictionary< int, QueryResult > resultMap
IMessageEnvelope CreateErrorResponse(IMessageEnvelope sourceMessage, Exception error)
IMessageEnvelope ProcessAuthenticate(IDictionary< string, object > metadata, AuthenticateRequest request)
QueryResultPart GetResultPart(int resultId, int startRow, int countRows)
IMessageEnvelope ProcessBegin(IDictionary< string, object > metadata)
The response to a command executed via the IDatabaseInterface.ExecuteQuery method in the IDatabaseInt...
The default implementation of a database in a system.
Definition: Database.cs:38
IMessageEnvelope CreateErrorResponse(IMessageEnvelope sourceMessage, string message)
int RowCount
Returns the row count.
Definition: QueryResult.cs:94
IDictionary< string, object > Metadata
The representation of a single database in the system.
Definition: IDatabase.cs:40
QueryResultColumn GetColumn(int columnOffset)
Definition: QueryResult.cs:102
IMessageEnvelope CreateEnvelope(IDictionary< string, object > metadata, IMessage message)
This is a session that is constructed around a given user and a transaction, to the given database...
Definition: Session.cs:32
IMessageEnvelope ProcessCreateLargeObject(IDictionary< string, object > metadata, LargeObjectCreateRequest request)
void OpenConnector(ConnectionEndPoint remoteEndPoint, string databaseName)
ITriggerChannel CreateTriggerChannel(string triggerName, string objectName, TriggerEventType eventType)
Defines the contract for a valid SQL Object
Definition: ISqlObject.cs:23
virtual bool OnAuthenticated(User user)
QueryResult GetResult(int resultId)
ObjectId CreateLargeObject(long objectLength)
IMessageEnvelope ProcessRollback(IDictionary< string, object > metadata, RollbackRequest request)
IMessageEnvelope ProcessConnect(IDictionary< string, object > metadata, ConnectRequest request)
IQueryResponse[] CoreExecuteQuery(IQuery context, string text, IEnumerable< QueryParameter > parameters)
IMessageEnvelope ProcessDisposeResult(IDictionary< string, object > metadata, DisposeResultRequest request)
ITransactionFactory TransactionFactory
Gets an object that is used to create new transactions to this database
Definition: Database.cs:89
QueryParameterStyle
In a SQL query object, this is the form of parameters passed from the client side to the server side...
A unique identifier of an object within a database system, that is composed by a reference to the sto...
Definition: ObjectId.cs:31
IMessageEnvelope ProcessMessage(IMessageEnvelope envelope)
void SetParameterStyle(QueryParameterStyle parameterStyle)
ServerConnector(IDatabaseHandler databaseHandler)
virtual void Dispose(bool disposing)
IQueryResponse[] ExecuteQuery(long commitId, string text, IEnumerable< QueryParameter > parameters)
void ChangeState(ConnectorState newState)
QueryResponse(int resultId, QueryResult queryResult, int millis, string warnings)
IMessageEnvelope ProcessQuery(IDictionary< string, object > metadata, QueryExecuteRequest request)
virtual IMessage GetMessage(IMessageEnvelope envelope)
IMessageEnvelope ProcessClose(IDictionary< string, object > metadata)
ILargeObjectChannel CreateObjectChannel(long objectId)
IQuery OpenQueryContext(long commitId)
Provides the information for a user in a database system
Definition: User.cs:27
ICollection< QueryParameter > Parameters
Definition: SqlQuery.cs:53
virtual EncryptionData GetEncryptionData()
virtual IQueryResponse[] ExecuteQuery(IQuery context, string text, IEnumerable< QueryParameter > parameters)
virtual bool Authenticate(string defaultSchema, string username, string password)
int ResultId
Returns a number that identifies this command within the set of queries executed on the connection...
TransactionCollection OpenTransactions
Gets the collection of currently open transactions.