DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Transaction.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.Linq;
20 
21 using Deveel.Data.Diagnostics;
22 using Deveel.Data.Index;
23 using Deveel.Data.Sql;
24 using Deveel.Data.Sql.Sequences;
25 using Deveel.Data.Sql.Tables;
26 using Deveel.Data.Sql.Triggers;
27 using Deveel.Data.Sql.Views;
28 
29 namespace Deveel.Data.Transactions {
36  private List<TableCommitCallback> callbacks;
37 
38  private Action<TableCommitInfo> commitActions;
39 
40  private static readonly TableInfo[] IntTableInfo;
41 
42  private readonly bool dbReadOnly;
43 
44  internal Transaction(ITransactionContext context, Database database, int commitId, IsolationLevel isolation, IEnumerable<TableSource> committedTables, IEnumerable<IIndexSet> indexSets) {
45  CommitId = commitId;
46  Database = database;
47  Isolation = isolation;
48  Context = context;
49 
50  context.RegisterInstance<ITransaction>(this);
51 
52  Registry = new TransactionRegistry(this);
53  TableManager.AddVisibleTables(committedTables, indexSets);
54 
55  AddInternalTables();
56 
57  TableState = new OldNewTableState();
58 
59  IsClosed = false;
60 
61  Database.TransactionFactory.OpenTransactions.AddTransaction(this);
62 
63  this.CurrentSchema(database.Context.DefaultSchema());
64  this.ReadOnly(database.Context.ReadOnly());
65  this.AutoCommit(database.Context.AutoCommit());
66  this.IgnoreIdentifiersCase(database.Context.IgnoreIdentifiersCase());
67  this.ParameterStyle(QueryParameterStyle.Marker);
68  }
69 
70  internal Transaction(ITransactionContext context, Database database, int commitId, IsolationLevel isolation)
71  : this(context, database, commitId, isolation, new TableSource[0], new IIndexSet[0]) {
72  }
73 
75  Dispose(false);
76  }
77 
78  static Transaction() {
79  IntTableInfo = new TableInfo[9];
80  IntTableInfo[0] = SystemSchema.TableInfoTableInfo;
81  IntTableInfo[1] = SystemSchema.TableColumnsTableInfo;
82  IntTableInfo[2] = SystemSchema.ProductInfoTableInfo;
83  IntTableInfo[3] = SystemSchema.VariablesTableInfo;
84  IntTableInfo[4] = SystemSchema.StatisticsTableInfo;
85  IntTableInfo[5] = SystemSchema.SessionInfoTableInfo;
86  IntTableInfo[6] = SystemSchema.OpenSessionsTableInfo;
87  IntTableInfo[7] = SystemSchema.SqlTypesTableInfo;
88  IntTableInfo[8] = SystemSchema.PrivilegesTableInfo;
89  }
90 
91  public int CommitId { get; private set; }
92 
93  public IsolationLevel Isolation { get; private set; }
94 
95  private bool IsClosed { get; set; }
96 
97  public OldNewTableState TableState { get; private set; }
98 
99  public ITransactionContext Context { get; private set; }
100 
101  public void SetTableState(OldNewTableState tableState) {
102  TableState = tableState;
103  }
104 
106  get { return Database; }
107  }
108 
109  public Database Database { get; private set; }
110 
112  get { return Database; }
113  }
114 
115  IEnumerable<KeyValuePair<string, object>> IEventSource.Metadata {
116  get { return new Dictionary<string, object> {
117  { KnownEventMetadata.CommitId, CommitId },
118  { KnownEventMetadata.IgnoreIdentifiersCase, this.IgnoreIdentifiersCase() },
119  { KnownEventMetadata.IsolationLevel, Isolation },
120  { KnownEventMetadata.CurrentSchema, this.CurrentSchema() },
121  { KnownEventMetadata.ReadOnlyTransaction, this.ReadOnly() }
122  };}
123  }
124 
126  get { return Context; }
127  }
128 
130  get { return Database.Context; }
131  }
132 
133  private TableSourceComposite TableComposite {
134  get { return Database.TableComposite; }
135  }
136 
138  get { return (SequenceManager) this.GetObjectManager(DbObjectType.Sequence); }
139  }
140 
142  get { return (ViewManager) this.GetObjectManager(DbObjectType.View); }
143  }
144 
146  get { return (TriggerManager) this.GetObjectManager(DbObjectType.Trigger); }
147  }
148 
149  public TransactionRegistry Registry { get; private set; }
150 
152  get { return this.GetTableManager(); }
153  }
154 
155  private void AddInternalTables() {
157 
158  // OLD and NEW system tables (if applicable)
160 
161  // Model views as tables (obviously)
163 
165  //tableManager.AddInternalTables(routineManager.CreateInternalTableInfo());
166 
167  // Model sequences as tables
169 
170  // Model triggers as tables
172  }
173 
174  private void AssertNotReadOnly() {
175  if (this.ReadOnly())
176  throw new TransactionException(TransactionErrorCodes.ReadOnly, "The transaction is in read-only mode.");
177  }
178 
179  public void Commit() {
180  if (!IsClosed) {
181  try {
182  var touchedTables = TableManager.AccessedTables.ToList();
183  var visibleTables = TableManager.GetVisibleTables().ToList();
184  var selected = TableManager.SelectedTables.ToArray();
185  TableComposite.Commit(this, visibleTables, selected, touchedTables, Registry, commitActions);
186 
187 
188  } finally {
189  Finish();
190  }
191  }
192  }
193 
194  public void RegisterOnCommit(Action<TableCommitInfo> action) {
195  if (commitActions == null) {
196  commitActions = action;
197  } else {
198  commitActions = Delegate.Combine(commitActions, action) as Action<TableCommitInfo>;
199  }
200  }
201 
202  public void UnregisterOnCommit(Action<TableCommitInfo> action) {
203  if (commitActions != null)
204  commitActions = Delegate.Remove(commitActions, action) as Action<TableCommitInfo>;
205  }
206 
207 
208  private void Finish() {
209  try {
210  // Dispose all the table we touched
211  try {
213 
214  if (Context != null)
215  Context.Dispose();
216 
217  } catch (Exception ex) {
218  this.OnError(ex);
219  }
220 
221  Registry = null;
222 
223  if (callbacks != null) {
224  foreach (var callback in callbacks) {
225  callback.OnTransactionEnd();
226  callback.DetachFrom(this);
227  }
228  }
229 
230  callbacks = null;
231  Context = null;
232 
233  // Dispose all the objects in the transaction
234  } finally {
235  IsClosed = true;
236  }
237  }
238 
239  public void Rollback() {
240  if (!IsClosed) {
241  try {
242  var touchedTables = TableManager.AccessedTables.ToList();
243  TableComposite.Rollback(this, touchedTables, Registry);
244  } finally {
245  IsClosed = true;
246  Finish();
247  }
248  }
249  }
250 
251  public void Dispose() {
252  Dispose(true);
253  GC.SuppressFinalize(this);
254  }
255 
256  private void Dispose(bool disposing) {
257  if (disposing) {
258  //if (!IsClosed)
259  // Rollback();
260  // TODO: review this ...
261  Finish();
262  }
263  }
264 
265  #region TransactionTableContainer
266 
268  private readonly Transaction transaction;
269  private readonly TableInfo[] tableInfos;
270 
271  public TransactionTableContainer(Transaction transaction, TableInfo[] tableInfos) {
272  this.transaction = transaction;
273  this.tableInfos = tableInfos;
274  }
275 
276  public int TableCount {
277  get { return tableInfos.Length; }
278  }
279 
280  public int FindByName(ObjectName name) {
281  var ignoreCase = transaction.IgnoreIdentifiersCase();
282  for (int i = 0; i < tableInfos.Length; i++) {
283  var info = tableInfos[i];
284  if (info != null &&
285  info.TableName.Equals(name, ignoreCase))
286  return i;
287  }
288 
289  return -1;
290  }
291 
292  public ObjectName GetTableName(int offset) {
293  if (offset < 0 || offset >= tableInfos.Length)
294  throw new ArgumentOutOfRangeException("offset");
295 
296  return tableInfos[offset].TableName;
297  }
298 
299  public TableInfo GetTableInfo(int offset) {
300  if (offset < 0 || offset >= tableInfos.Length)
301  throw new ArgumentOutOfRangeException("offset");
302 
303  return tableInfos[offset];
304  }
305 
306  public string GetTableType(int offset) {
307  return TableTypes.SystemTable;
308  }
309 
310  public bool ContainsTable(ObjectName name) {
311  return FindByName(name) >= 0;
312  }
313 
314  public ITable GetTable(int offset) {
315  if (offset == 0)
316  return SystemSchema.GetTableInfoTable(transaction);
317  if (offset == 1)
318  return SystemSchema.GetTableColumnsTable(transaction);
319  if (offset == 2)
320  return SystemSchema.GetProductInfoTable(transaction);
321  if (offset == 3)
322  return SystemSchema.GetVariablesTable(transaction);
323  if (offset == 4)
324  return SystemSchema.GetStatisticsTable(transaction);
325  /*
326  TODO:
327  if (offset == 5)
328  return SystemSchema.GetSessionInfoTable(transaction);
329  */
330  if (offset == 6)
331  return SystemSchema.GetOpenSessionsTable(transaction);
332  if (offset == 7)
333  return SystemSchema.GetSqlTypesTable(transaction);
334  if (offset == 8)
335  return SystemSchema.GetPrivilegesTable(transaction);
336 
337  throw new ArgumentOutOfRangeException("offset");
338  }
339  }
340 
341  #endregion
342 
343  #region OldAndNewTableContainer
344 
346  private readonly Transaction transaction;
347 
348  public OldAndNewTableContainer(Transaction transaction) {
349  this.transaction = transaction;
350  }
351 
352  private bool HasOldTable {
353  get { return transaction.TableState.OldRowIndex != -1; }
354  }
355 
356  private bool HasNewTable {
357  get { return transaction.TableState.NewDataRow != null; }
358  }
359 
360 
361  public int TableCount {
362  get {
363  int count = 0;
364  if (HasOldTable)
365  ++count;
366  if (HasNewTable)
367  ++count;
368  return count;
369  }
370  }
371 
372  public int FindByName(ObjectName name) {
373  if (HasOldTable &&
374  name.Equals(SystemSchema.OldTriggerTableName, transaction.IgnoreIdentifiersCase()))
375  return 0;
376  if (HasNewTable &&
377  name.Equals(SystemSchema.NewTriggerTableName, transaction.IgnoreIdentifiersCase()))
378  return HasOldTable ? 1 : 0;
379  return -1;
380  }
381 
382  public ObjectName GetTableName(int offset) {
383  if (HasOldTable && offset == 0)
385 
387  }
388 
389  public TableInfo GetTableInfo(int offset) {
390  var tableInfo = transaction.GetTableInfo(transaction.TableState.TableSource);
391  return tableInfo.Alias(GetTableName(offset));
392  }
393 
394  public string GetTableType(int offset) {
395  return TableTypes.SystemTable;
396  }
397 
398  public bool ContainsTable(ObjectName name) {
399  return FindByName(name) > 0;
400  }
401 
402  public ITable GetTable(int offset) {
403  var tableInfo = GetTableInfo(offset);
404 
405  var table = new TriggeredOldNew(transaction.DatabaseContext, tableInfo);
406 
407  if (HasOldTable) {
408  if (offset == 0) {
409  // Copy data from the table to the new table
410  var dtable = transaction.GetTable(transaction.TableState.TableSource);
411  var oldRow = new Row(table);
412  int rowIndex = transaction.TableState.OldRowIndex;
413  for (int i = 0; i < tableInfo.ColumnCount; ++i) {
414  oldRow.SetValue(i, dtable.GetValue(rowIndex, i));
415  }
416 
417  // All OLD tables are immutable
418  table.SetReadOnly(true);
419  table.SetData(oldRow);
420 
421  return table;
422  }
423  }
424 
425  table.SetReadOnly(!transaction.TableState.IsNewMutable);
426  table.SetData(transaction.TableState.NewDataRow);
427 
428  return table;
429  }
430 
431  #region TriggeredOldNew
432 
434  private readonly TableInfo tableInfo;
435  private Row data;
436  private bool readOnly;
437 
438  public TriggeredOldNew(IDatabaseContext dbContext, TableInfo tableInfo)
439  : base(dbContext) {
440  this.tableInfo = tableInfo;
441  }
442 
443  public override TableInfo TableInfo {
444  get { return tableInfo; }
445  }
446 
447  public override int RowCount {
448  get { return 1; }
449  }
450 
451  public void SetData(Row row) {
452  data = row;
453  }
454 
455  public void SetReadOnly(bool flag) {
456  readOnly = flag;
457  }
458 
459  public override DataObject GetValue(long rowNumber, int columnOffset) {
460  if (rowNumber < 0 || rowNumber >= 1)
461  throw new ArgumentOutOfRangeException("rowNumber");
462 
463  return data.GetValue(columnOffset);
464  }
465 
467  get { throw new InvalidOperationException(); }
468  }
469 
470  public RowId AddRow(Row row) {
471  throw new NotSupportedException(String.Format("Inserting data into '{0}' is not allowed.", tableInfo.TableName));
472  }
473 
474  public void UpdateRow(Row row) {
475  if (row.RowId.RowNumber < 0 ||
476  row.RowId.RowNumber >= 1)
477  throw new ArgumentOutOfRangeException();
478  if (readOnly)
479  throw new NotSupportedException(String.Format("Updating '{0}' is not permitted.", tableInfo.TableName));
480 
481  int sz = TableInfo.ColumnCount;
482  for (int i = 0; i < sz; ++i) {
483  data.SetValue(i, row.GetValue(i));
484  }
485  }
486 
487  public bool RemoveRow(RowId rowId) {
488  throw new NotSupportedException(String.Format("Deleting data from '{0}' is not allowed.", tableInfo.TableName));
489  }
490 
491  public void FlushIndexes() {
492  }
493 
494  public void AssertConstraints() {
495  }
496 
497  public void AddLock() {
498  }
499 
500  public void RemoveLock() {
501  }
502  }
503 
504  #endregion
505  }
506 
507  #endregion
508 
509  //#region ObjectManagersResolver
510 
511  //class ObjectManagersResolver : IObjectManagerResolver {
512  // private readonly Transaction transaction;
513 
514  // public ObjectManagersResolver(Transaction transaction) {
515  // this.transaction = transaction;
516  // }
517 
518  // public IEnumerable<IObjectManager> ResolveAll() {
519  // return new IObjectManager[] {
520  // transaction.schemaManager,
521  // transaction.tableManager,
522  // transaction.sequenceManager,
523  // transaction.variableManager,
524  // transaction.viewManager,
525  // transaction.triggerManager
526  // };
527  // }
528 
529  // public IObjectManager ResolveForType(DbObjectType objType) {
530  // if (objType == DbObjectType.Schema)
531  // return transaction.schemaManager;
532  // if (objType == DbObjectType.Table)
533  // return transaction.tableManager;
534  // if (objType == DbObjectType.Sequence)
535  // return transaction.sequenceManager;
536  // if (objType == DbObjectType.Variable)
537  // return transaction.variableManager;
538  // if (objType == DbObjectType.View)
539  // return transaction.viewManager;
540  // if (objType == DbObjectType.Trigger)
541  // return transaction.triggerManager;
542 
543  // return null;
544  // }
545  //}
546 
547  //#endregion
548 
549  #region Variables
550  /*
551  void IVariableScope.OnVariableDefined(Variable variable) {
552  if (variable.Name.Equals(TransactionSettingKeys.CurrentSchema, StringComparison.OrdinalIgnoreCase)) {
553  currentSchema = variable.Value;
554  } else if (variable.Name.Equals(TransactionSettingKeys.ReadOnly, StringComparison.OrdinalIgnoreCase)) {
555  if (dbReadOnly)
556  throw new InvalidOperationException("The database is read-only: cannot change access of the transaction.");
557 
558  // TODO: handle special cases like "ON", "OFF", "ENABLE" and "DISABLE"
559  readOnly = ParseBoolean(variable.Value);
560  } else if (variable.Name.Equals(TransactionSettingKeys.IgnoreIdentifiersCase, StringComparison.OrdinalIgnoreCase)) {
561  ignoreCase = ParseBoolean(variable.Value);
562  } else if (variable.Name.Equals(TransactionSettingKeys.AutoCommit, StringComparison.OrdinalIgnoreCase)) {
563  autoCommit = ParseBoolean(variable.Value);
564  } else if (variable.Name.Equals(TransactionSettingKeys.ParameterStyle, StringComparison.OrdinalIgnoreCase)) {
565  parameterStyle = variable.Value;
566  } else if (variable.Name.Equals(TransactionSettingKeys.IsolationLevel, StringComparison.OrdinalIgnoreCase)) {
567  var isolation = ParseIsolationLevel(variable.Value);
568  //TODO: support multiple isolations!
569  if (isolation != IsolationLevel.Serializable)
570  throw new NotSupportedException();
571  }
572  }
573 
574  private static IsolationLevel ParseIsolationLevel(DataObject value) {
575  var s = value.Value.ToString();
576  if (String.Equals(s, "serializable", StringComparison.OrdinalIgnoreCase))
577  return IsolationLevel.Serializable;
578  if (String.Equals(s, "read committed", StringComparison.OrdinalIgnoreCase))
579  return IsolationLevel.ReadCommitted;
580  if (String.Equals(s, "read uncommitted", StringComparison.OrdinalIgnoreCase))
581  return IsolationLevel.ReadUncommitted;
582  if (String.Equals(s, "snapshot", StringComparison.OrdinalIgnoreCase))
583  return IsolationLevel.Snapshot;
584 
585  return IsolationLevel.Unspecified;
586  }
587 
588  private static bool ParseBoolean(DataObject value) {
589  if (value.Type is BooleanType)
590  return value;
591  if (value.Type is StringType) {
592  var s = value.Value.ToString();
593  if (String.Equals(s, "true", StringComparison.OrdinalIgnoreCase) ||
594  String.Equals(s, "on", StringComparison.OrdinalIgnoreCase))
595  return true;
596  if (String.Equals(s, "false", StringComparison.OrdinalIgnoreCase) ||
597  String.Equals(s, "off", StringComparison.OrdinalIgnoreCase))
598  return false;
599  } else if (value.Type is NumericType) {
600  int i = value;
601  if (i == 0)
602  return false;
603  if (i == 1)
604  return true;
605  }
606 
607  throw new NotSupportedException();
608  }
609 
610  void IVariableScope.OnVariableDropped(Variable variable) {
611  if (variable.Name.Equals(TransactionSettingKeys.CurrentSchema, StringComparison.OrdinalIgnoreCase)) {
612  currentSchema = Database.DatabaseContext.DefaultSchema();
613  } else if (variable.Name.Equals(TransactionSettingKeys.ReadOnly, StringComparison.OrdinalIgnoreCase)) {
614  readOnly = dbReadOnly;
615  } else if (variable.Name.Equals(TransactionSettingKeys.IgnoreIdentifiersCase, StringComparison.OrdinalIgnoreCase)) {
616  ignoreCase = Database.DatabaseContext.IgnoreIdentifiersCase();
617  } else if (variable.Name.Equals(TransactionSettingKeys.AutoCommit, StringComparison.OrdinalIgnoreCase)) {
618  autoCommit = Database.DatabaseContext.AutoCommit();
619  } else if (variable.Name.Equals(TransactionSettingKeys.ParameterStyle, StringComparison.OrdinalIgnoreCase)) {
620  // TODO: Get it from the configuration...
621  parameterStyle = null;
622  }
623  }
624 
625  private Variable MakeStringVariable(string name, string value) {
626  var variable = new Variable(new VariableInfo(name, PrimitiveTypes.String(), false));
627  variable.SetValue(DataObject.String(value));
628  return variable;
629  }
630 
631  private Variable MakeBooleanVariable(string name, bool value) {
632  var variable = new Variable(new VariableInfo(name, PrimitiveTypes.Boolean(), false));
633  variable.SetValue(DataObject.Boolean(value));
634  return variable;
635  }
636 
637  Variable IVariableScope.OnVariableGet(string name) {
638  if (name.Equals(TransactionSettingKeys.CurrentSchema, StringComparison.OrdinalIgnoreCase))
639  return MakeStringVariable(TransactionSettingKeys.CurrentSchema, currentSchema);
640  if (name.Equals(TransactionSettingKeys.ReadOnly, StringComparison.OrdinalIgnoreCase))
641  return MakeBooleanVariable(TransactionSettingKeys.ReadOnly, readOnly);
642  if (name.Equals(TransactionSettingKeys.IgnoreIdentifiersCase, StringComparison.OrdinalIgnoreCase))
643  return MakeBooleanVariable(TransactionSettingKeys.IgnoreIdentifiersCase, ignoreCase);
644  if (name.Equals(TransactionSettingKeys.AutoCommit, StringComparison.OrdinalIgnoreCase))
645  return MakeBooleanVariable(TransactionSettingKeys.AutoCommit, autoCommit);
646  if (name.Equals(TransactionSettingKeys.ParameterStyle, StringComparison.OrdinalIgnoreCase))
647  return MakeStringVariable(TransactionSettingKeys.ParameterStyle, parameterStyle);
648 
649  return null;
650  }
651  */
652 
653  #endregion
654 
656  if (callbacks == null)
657  callbacks = new List<TableCommitCallback>();
658 
659  callbacks.Add(callback);
660  }
661 
663  if (callbacks == null)
664  return;
665 
666  for (int i = callbacks.Count - 1; i >= 0; i--) {
667  var other = callbacks[i];
668  if (other.TableName.Equals(callback.TableName))
669  callbacks.RemoveAt(i);
670  }
671  }
672  }
673 }
static readonly TableInfo SqlTypesTableInfo
static ITable GetPrivilegesTable(ITransaction transaction)
Defines the contract to access the data contained into a table of a database.
Definition: ITable.cs:40
static ITable GetOpenSessionsTable(ITransaction transaction)
void OnCallbackDetached(TableCommitCallback callback)
static readonly TableInfo[] IntTableInfo
Definition: Transaction.cs:40
ObjectName GetTableName(int offset)
Gets the name of the table at the given index in this container.
Definition: Transaction.cs:292
void OnCallbackAttached(TableCommitCallback callback)
The context of a single database within a system.
The system implementation of a transaction model that handles isolated operations within a database c...
Definition: Transaction.cs:35
static ITable GetSqlTypesTable(ITransaction transaction)
ObjectName GetTableName(int offset)
Gets the name of the table at the given index in this container.
Definition: Transaction.cs:382
IEnumerable< IMutableTable > AccessedTables
Definition: TableManager.cs:61
void Commit()
Commits all write operation done during the lifetime of this transaction and invalidates it...
Definition: Transaction.cs:179
void RegisterOnCommit(Action< TableCommitInfo > action)
Definition: Transaction.cs:194
DataObject GetValue(int columnOffset)
Gets or the value of a cell of the row at the given offset.
Definition: Row.cs:203
bool RemoveRow(RowId rowId)
Deletes row identified by the given coordinates from the table.
Definition: Transaction.cs:487
string GetTableType(int offset)
Gets the type of the table at the given offset.
Definition: Transaction.cs:394
ITable GetTable(int offset)
Gets the table contained at the given offset within the context.
Definition: Transaction.cs:314
int FindByName(ObjectName name)
Finds the index in this container of the given table by its name.
Definition: Transaction.cs:280
static readonly TableInfo TableInfoTableInfo
virtual void Dispose(bool disposing)
Definition: Context.cs:63
TableInfo GetTableInfo(int offset)
Gets the information of the table at the given offset in this container.
Definition: Transaction.cs:299
IEnumerable< ITableSource > SelectedTables
Definition: TableManager.cs:65
The default implementation of a database in a system.
Definition: Database.cs:38
Describes the name of an object within a database.
Definition: ObjectName.cs:44
IDatabase Database
Gets the database this transaction belongs to.
Definition: ITransaction.cs:48
static readonly TableInfo TableColumnsTableInfo
void SetTableState(OldNewTableState tableState)
Definition: Transaction.cs:101
static ITable GetVariablesTable(ITransaction transaction)
A single row in a table of a database.
Definition: Row.cs:44
ITableContainer CreateInternalTableInfo()
Definition: ViewManager.cs:236
override bool Equals(object obj)
Definition: ObjectName.cs:241
void AddVisibleTables(IEnumerable< TableSource > tableSources, IEnumerable< IIndexSet > indexSets)
The representation of a single database in the system.
Definition: IDatabase.cs:40
IContext IEventSource. Context
Definition: Database.cs:95
string GetTableType(int offset)
Gets the type of the table at the given offset.
Definition: Transaction.cs:306
static readonly TableInfo PrivilegesTableInfo
int RowNumber
Gets the number of the column within the table referenced.
Definition: RowId.cs:58
void AssertConstraints()
Performs all constraint integrity checks and actions to any modifications based on any changes that h...
Definition: Transaction.cs:494
TableInfo Alias(ObjectName alias)
Definition: TableInfo.cs:346
IEventSource ParentSource
Gets an optional parent source.
Definition: IEventSource.cs:49
void Rollback()
Rollback any write operations done during the lifetime of this transaction and invalidates it...
Definition: Transaction.cs:239
A default implementation of a sequence manager that is backed by a given transaction.
static ITable GetStatisticsTable(ITransaction transaction)
IEnumerable< KeyValuePair< string, object > > Metadata
Gets the list of metadata associated to the source.
Definition: IEventSource.cs:57
static readonly TableInfo ProductInfoTableInfo
bool ContainsTable(ObjectName name)
Checks if a table with the given name is contained in the current context.
Definition: Transaction.cs:398
static readonly TableInfo StatisticsTableInfo
Provides the constant names of the types of tables in a database system.
Definition: TableTypes.cs:24
void AddInternalTables(ITableContainer container)
const string SystemTable
Definition: TableTypes.cs:26
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
Transaction(ITransactionContext context, Database database, int commitId, IsolationLevel isolation, IEnumerable< TableSource > committedTables, IEnumerable< IIndexSet > indexSets)
Definition: Transaction.cs:44
A container for any system tables that are generated from information inside the database engine...
static readonly TableInfo VariablesTableInfo
TriggeredOldNew(IDatabaseContext dbContext, TableInfo tableInfo)
Definition: Transaction.cs:438
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...
Provides utilities and properties for handling the SYSTEN schema of a database.
Definition: SystemSchema.cs:37
static readonly TableInfo OpenSessionsTableInfo
An object that access to a set of indexes.
Definition: IIndexSet.cs:27
bool ContainsTable(ObjectName name)
Checks if a table with the given name is contained in the current context.
Definition: Transaction.cs:310
IEnumerable< ITableSource > GetVisibleTables()
Defines the value of a ROWID object, that is a unique reference within a database system to a single ...
Definition: RowId.cs:24
void UnregisterOnCommit(Action< TableCommitInfo > action)
Definition: Transaction.cs:202
void FlushIndexes()
Flushes all changes made on this table to the backing index scheme.
Definition: Transaction.cs:491
List< TableCommitCallback > callbacks
Definition: Transaction.cs:36
void SetValue(int columnOffset, DataObject value)
Sets the value of a cell of the row at the given offset.
Definition: Row.cs:247
TableInfo GetTableInfo(int offset)
Gets the information of the table at the given offset in this container.
Definition: Transaction.cs:389
override DataObject GetValue(long rowNumber, int columnOffset)
Gets a single cell within the table that is located at the given column offset and row...
Definition: Transaction.cs:459
int ColumnCount
Gets a count of the columns defined by this object.
Definition: TableInfo.cs:159
ITable GetTable(int offset)
Gets the table contained at the given offset within the context.
Definition: Transaction.cs:402
int FindByName(ObjectName name)
Finds the index in this container of the given table by its name.
Definition: Transaction.cs:372
TableSourceComposite TableComposite
Definition: Database.cs:192
static readonly ObjectName OldTriggerTableName
The simplest implementation of a transaction.
Definition: ITransaction.cs:30
Transaction(ITransactionContext context, Database database, int commitId, IsolationLevel isolation)
Definition: Transaction.cs:70
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
Action< TableCommitInfo > commitActions
Definition: Transaction.cs:38
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
static ITable GetTableColumnsTable(ITransaction transaction)
static ITable GetTableInfoTable(ITransaction transaction)
static readonly TableInfo SessionInfoTableInfo
static ITable GetProductInfoTable(ITransaction transaction)
An interface that defines contracts to alter the contents of a table.
TransactionTableContainer(Transaction transaction, TableInfo[] tableInfos)
Definition: Transaction.cs:271
void UpdateRow(Row row)
Updates the values of a row into the table.
Definition: Transaction.cs:474
Represents the origin of system events, providing a mechanism to fill the metadata before dispatching...
Definition: IEventSource.cs:40
static readonly ObjectName NewTriggerTableName
RowId RowId
Gets the row unique identifier within the database.
Definition: Row.cs:101