DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Static Public Member Functions | Static Package Functions | Static Private Member Functions | List of all members
Deveel.Data.Sql.Tables.QueryExtensions Class Reference

Static Public Member Functions

static int DeleteFrom (this IQuery context, ObjectName tableName, SqlQueryExpression query)
 
static int DeleteFrom (this IQuery context, ObjectName tableName, SqlExpression expression)
 
static int DeleteFrom (this IQuery context, ObjectName tableName, SqlExpression expression, int limit)
 
static int DeleteFrom (this IQuery context, ObjectName tableName, SqlQueryExpression query, int limit)
 
static int DeleteFrom (this IQuery context, ObjectName tableName, ITable deleteSet, int limit)
 
static int UpdateTable (this IQuery context, ObjectName tableName, IQueryPlanNode queryPlan, IEnumerable< SqlAssignExpression > assignments, int limit)
 
static void InsertIntoTable (this IQuery context, ObjectName tableName, IEnumerable< SqlAssignExpression > assignments)
 
static int InsertIntoTable (this IQuery context, ObjectName tableName, IEnumerable< SqlAssignExpression[]> assignments)
 
static ObjectName ResolveTableName (this IQuery query, ObjectName tableName)
 
static ObjectName ResolveTableName (this IQuery query, string name)
 
static bool TableExists (this IQuery query, ObjectName tableName)
 
static void CreateTable (this IQuery query, TableInfo tableInfo)
 
static void CreateTable (this IQuery query, TableInfo tableInfo, bool onlyIfNotExists)
 
static void CreateTable (this IQuery query, TableInfo tableInfo, bool onlyIfNotExists, bool temporary)
 
static ITableQueryInfo GetTableQueryInfo (this IQuery context, ObjectName tableName, ObjectName alias)
 
static void DropTables (this IQuery query, IEnumerable< ObjectName > tableNames)
 
static void DropTables (this IQuery query, IEnumerable< ObjectName > tableNames, bool onlyIfExists)
 
static void DropTable (this IQuery query, ObjectName tableName)
 
static void DropTable (this IQuery query, ObjectName tableName, bool onlyIfExists)
 
static void AlterTable (this IQuery query, TableInfo tableInfo)
 
static ITable GetTable (this IQuery query, ObjectName tableName)
 
static IMutableTable GetMutableTable (this IQuery query, ObjectName tableName)
 
static ITable GetCachedTable (this IQuery query, string cacheKey)
 
static void CacheTable (this IQuery query, string cacheKey, ITable table)
 
static void ClearCachedTables (this IQuery query)
 
static void AddPrimaryKey (this IQuery query, ObjectName tableName, string[] columnNames)
 
static void AddPrimaryKey (this IQuery query, ObjectName tableName, string[] columnNames, string constraintName)
 
static void AddPrimaryKey (this IQuery query, ObjectName tableName, string columnName)
 
static void AddPrimaryKey (this IQuery query, ObjectName tableName, string columnName, string constraintName)
 
static void AddForeignKey (this IQuery query, ObjectName table, string[] columns, ObjectName refTable, string[] refColumns, ForeignKeyAction deleteRule, ForeignKeyAction updateRule, String constraintName)
 
static void AddForeignKey (this IQuery query, ObjectName table, string[] columns, ObjectName refTable, string[] refColumns, ForeignKeyAction deleteRule, ForeignKeyAction updateRule, ConstraintDeferrability deferred, String constraintName)
 
static void AddUniqueKey (this IQuery query, ObjectName tableName, string[] columns)
 
static void AddUniqueKey (this IQuery query, ObjectName tableName, string[] columns, string constraintName)
 
static void AddUniqueKey (this IQuery query, ObjectName tableName, string[] columns, ConstraintDeferrability deferrability)
 
static void AddUniqueKey (this IQuery query, ObjectName tableName, string[] columns, ConstraintDeferrability deferrability, string constraintName)
 
static void AddCheck (this IQuery query, ObjectName tableName, SqlExpression expression, string constraintName)
 
static void AddCheck (this IQuery query, ObjectName tableName, SqlExpression expression, ConstraintDeferrability deferred, string constraintName)
 
static void DropAllTableConstraints (this IQuery query, ObjectName tableName)
 
static int DropConstraint (this IQuery query, ObjectName tableName, string constraintName)
 
static void AddConstraint (this IQuery query, ObjectName tableName, ConstraintInfo constraintInfo)
 
static bool DropPrimaryKey (this IQuery query, ObjectName tableName, string constraintName)
 
static void CheckConstraints (this IQuery query, ObjectName tableName)
 
static ConstraintInfo[] GetTableCheckExpressions (this IQuery query, ObjectName tableName)
 
static ConstraintInfo[] GetTableImportedForeignKeys (this IQuery query, ObjectName tableName)
 
static ConstraintInfo[] GetTableForeignKeys (this IQuery query, ObjectName tableName)
 
static ConstraintInfo GetTablePrimaryKey (this IQuery query, ObjectName tableName)
 
static ConstraintInfo[] GetTableUniqueKeys (this IQuery query, ObjectName tableName)
 

Static Package Functions

static void CreateSystemTable (this IQuery query, TableInfo tableInfo)
 

Static Private Member Functions

static ICache TableCache (this IQuery query)
 

Detailed Description

Definition at line 28 of file QueryExtensions.Commands.cs.

Member Function Documentation

static void Deveel.Data.Sql.Tables.QueryExtensions.AddCheck ( this IQuery  query,
ObjectName  tableName,
SqlExpression  expression,
string  constraintName 
)
inlinestatic

Definition at line 276 of file QueryExtensions.cs.

276  {
277  AddCheck(query, tableName, expression, ConstraintDeferrability.InitiallyImmediate, constraintName);
278  }
static void AddCheck(this IQuery query, ObjectName tableName, SqlExpression expression, string constraintName)
ConstraintDeferrability
The type of deferrance of a constraint.
static void Deveel.Data.Sql.Tables.QueryExtensions.AddCheck ( this IQuery  query,
ObjectName  tableName,
SqlExpression  expression,
ConstraintDeferrability  deferred,
string  constraintName 
)
inlinestatic

Definition at line 280 of file QueryExtensions.cs.

280  {
281  query.Session.AddCheck(tableName, expression, deferred, constraintName);
282  }
static void Deveel.Data.Sql.Tables.QueryExtensions.AddConstraint ( this IQuery  query,
ObjectName  tableName,
ConstraintInfo  constraintInfo 
)
inlinestatic

Definition at line 292 of file QueryExtensions.cs.

292  {
293  if (constraintInfo.ConstraintType == ConstraintType.PrimaryKey) {
294  var columnNames = constraintInfo.ColumnNames;
295  if (columnNames.Length > 1)
296  throw new ArgumentException();
297 
298  query.AddPrimaryKey(tableName, columnNames[0], constraintInfo.ConstraintName);
299  } else if (constraintInfo.ConstraintType == ConstraintType.Unique) {
300  query.AddUniqueKey(tableName, constraintInfo.ColumnNames, constraintInfo.ConstraintName);
301  } else if (constraintInfo.ConstraintType == ConstraintType.Check) {
302  query.AddCheck(tableName, constraintInfo.CheckExpression, constraintInfo.ConstraintName);
303  } else if (constraintInfo.ConstraintType == ConstraintType.ForeignKey) {
304  query.AddForeignKey(tableName, constraintInfo.ColumnNames, constraintInfo.ForeignTable,
305  constraintInfo.ForeignColumnNames, constraintInfo.OnDelete, constraintInfo.OnUpdate, constraintInfo.ConstraintName);
306  }
307  }
ConstraintType
An enumeration of all the supported kinds of constraints within a table or a schema.
static void Deveel.Data.Sql.Tables.QueryExtensions.AddForeignKey ( this IQuery  query,
ObjectName  table,
string[]  columns,
ObjectName  refTable,
string[]  refColumns,
ForeignKeyAction  deleteRule,
ForeignKeyAction  updateRule,
String  constraintName 
)
inlinestatic

Definition at line 238 of file QueryExtensions.cs.

240  {
241  AddForeignKey(query, table, columns, refTable, refColumns, deleteRule, updateRule, ConstraintDeferrability.InitiallyImmediate, constraintName);
242  }
ConstraintDeferrability
The type of deferrance of a constraint.
static void AddForeignKey(this IQuery query, ObjectName table, string[] columns, ObjectName refTable, string[] refColumns, ForeignKeyAction deleteRule, ForeignKeyAction updateRule, String constraintName)
static void Deveel.Data.Sql.Tables.QueryExtensions.AddForeignKey ( this IQuery  query,
ObjectName  table,
string[]  columns,
ObjectName  refTable,
string[]  refColumns,
ForeignKeyAction  deleteRule,
ForeignKeyAction  updateRule,
ConstraintDeferrability  deferred,
String  constraintName 
)
inlinestatic

Definition at line 244 of file QueryExtensions.cs.

246  {
247  if (!query.UserCanAlterTable(table))
248  throw new MissingPrivilegesException(query.UserName(), table, Privileges.Alter);
249  if (!query.UserCanReferenceTable(refTable))
250  throw new MissingPrivilegesException(query.UserName(), refTable, Privileges.References);
251 
252  query.Session.AddForeignKey(table, columns, refTable, refColumns, deleteRule, updateRule, deferred, constraintName);
253  }
static void Deveel.Data.Sql.Tables.QueryExtensions.AddPrimaryKey ( this IQuery  query,
ObjectName  tableName,
string[]  columnNames 
)
inlinestatic

Definition at line 219 of file QueryExtensions.cs.

219  {
220  AddPrimaryKey(query, tableName, columnNames, null);
221  }
static void AddPrimaryKey(this IQuery query, ObjectName tableName, string[] columnNames)
static void Deveel.Data.Sql.Tables.QueryExtensions.AddPrimaryKey ( this IQuery  query,
ObjectName  tableName,
string[]  columnNames,
string  constraintName 
)
inlinestatic

Definition at line 223 of file QueryExtensions.cs.

223  {
224  if (!query.UserCanAlterTable(tableName))
225  throw new MissingPrivilegesException(query.UserName(), tableName, Privileges.Alter);
226 
227  query.Session.AddPrimaryKey(tableName, columnNames, ConstraintDeferrability.InitiallyImmediate, constraintName);
228  }
ConstraintDeferrability
The type of deferrance of a constraint.
static void Deveel.Data.Sql.Tables.QueryExtensions.AddPrimaryKey ( this IQuery  query,
ObjectName  tableName,
string  columnName 
)
inlinestatic

Definition at line 230 of file QueryExtensions.cs.

230  {
231  AddPrimaryKey(query, tableName, columnName, null);
232  }
static void AddPrimaryKey(this IQuery query, ObjectName tableName, string[] columnNames)
static void Deveel.Data.Sql.Tables.QueryExtensions.AddPrimaryKey ( this IQuery  query,
ObjectName  tableName,
string  columnName,
string  constraintName 
)
inlinestatic

Definition at line 234 of file QueryExtensions.cs.

234  {
235  query.AddPrimaryKey(tableName, new[] { columnName }, constraintName);
236  }
static void Deveel.Data.Sql.Tables.QueryExtensions.AddUniqueKey ( this IQuery  query,
ObjectName  tableName,
string[]  columns 
)
inlinestatic

Definition at line 255 of file QueryExtensions.cs.

255  {
256  AddUniqueKey(query, tableName, columns, null);
257  }
static void AddUniqueKey(this IQuery query, ObjectName tableName, string[] columns)
static void Deveel.Data.Sql.Tables.QueryExtensions.AddUniqueKey ( this IQuery  query,
ObjectName  tableName,
string[]  columns,
string  constraintName 
)
inlinestatic

Definition at line 259 of file QueryExtensions.cs.

259  {
260  AddUniqueKey(query, tableName, columns, ConstraintDeferrability.InitiallyImmediate, constraintName);
261  }
static void AddUniqueKey(this IQuery query, ObjectName tableName, string[] columns)
ConstraintDeferrability
The type of deferrance of a constraint.
static void Deveel.Data.Sql.Tables.QueryExtensions.AddUniqueKey ( this IQuery  query,
ObjectName  tableName,
string[]  columns,
ConstraintDeferrability  deferrability 
)
inlinestatic

Definition at line 263 of file QueryExtensions.cs.

264  {
265  AddUniqueKey(query, tableName, columns, deferrability, null);
266  }
static void AddUniqueKey(this IQuery query, ObjectName tableName, string[] columns)
static void Deveel.Data.Sql.Tables.QueryExtensions.AddUniqueKey ( this IQuery  query,
ObjectName  tableName,
string[]  columns,
ConstraintDeferrability  deferrability,
string  constraintName 
)
inlinestatic

Definition at line 268 of file QueryExtensions.cs.

269  {
270  if (!query.UserCanAlterTable(tableName))
271  throw new MissingPrivilegesException(query.UserName(), tableName, Privileges.Alter);
272 
273  query.Session.AddUniqueKey(tableName, columns, deferrability, constraintName);
274  }
static void Deveel.Data.Sql.Tables.QueryExtensions.AlterTable ( this IQuery  query,
TableInfo  tableInfo 
)
inlinestatic

Definition at line 164 of file QueryExtensions.cs.

164  {
165  query.AlterObject(tableInfo);
166  }
static void Deveel.Data.Sql.Tables.QueryExtensions.CacheTable ( this IQuery  query,
string  cacheKey,
ITable  table 
)
inlinestatic

Definition at line 201 of file QueryExtensions.cs.

201  {
202  var tableCache = query.TableCache();
203  if (tableCache == null)
204  return;
205 
206  tableCache.Set(cacheKey, table);
207  }
static void Deveel.Data.Sql.Tables.QueryExtensions.CheckConstraints ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 313 of file QueryExtensions.cs.

313  {
314  query.Session.CheckConstraintViolations(tableName);
315  }
static void Deveel.Data.Sql.Tables.QueryExtensions.ClearCachedTables ( this IQuery  query)
inlinestatic

Definition at line 209 of file QueryExtensions.cs.

209  {
210  var tableCache = query.TableCache();
211  if (tableCache == null)
212  return;
213 
214  tableCache.Clear();
215  }
static void Deveel.Data.Sql.Tables.QueryExtensions.CreateSystemTable ( this IQuery  query,
TableInfo  tableInfo 
)
inlinestaticpackage

Definition at line 91 of file QueryExtensions.cs.

91  {
92  if (tableInfo == null)
93  throw new ArgumentNullException("tableInfo");
94 
95  var tableName = tableInfo.TableName;
96 
97  if (!query.UserCanCreateTable(tableName))
98  throw new MissingPrivilegesException(query.User().Name, tableName, Privileges.Create);
99 
100  query.Session.CreateTable(tableInfo, false);
101  }
static void Deveel.Data.Sql.Tables.QueryExtensions.CreateTable ( this IQuery  query,
TableInfo  tableInfo 
)
inlinestatic

Definition at line 55 of file QueryExtensions.cs.

55  {
56  CreateTable(query, tableInfo, false);
57  }
static void CreateTable(this IQuery query, TableInfo tableInfo)
static void Deveel.Data.Sql.Tables.QueryExtensions.CreateTable ( this IQuery  query,
TableInfo  tableInfo,
bool  onlyIfNotExists 
)
inlinestatic

Definition at line 59 of file QueryExtensions.cs.

59  {
60  CreateTable(query, tableInfo, onlyIfNotExists, false);
61  }
static void CreateTable(this IQuery query, TableInfo tableInfo)
static void Deveel.Data.Sql.Tables.QueryExtensions.CreateTable ( this IQuery  query,
TableInfo  tableInfo,
bool  onlyIfNotExists,
bool  temporary 
)
inlinestatic

Definition at line 63 of file QueryExtensions.cs.

63  {
64  if (tableInfo == null)
65  throw new ArgumentNullException("tableInfo");
66 
67  var tableName = tableInfo.TableName;
68 
69  if (!query.UserCanCreateTable(tableName))
70  throw new MissingPrivilegesException(query.User().Name, tableName, Privileges.Create);
71 
72  if (query.TableExists(tableName)) {
73  if (!onlyIfNotExists)
74  throw new InvalidOperationException(
75  String.Format("The table {0} already exists and the IF NOT EXISTS clause was not specified.", tableName));
76 
77  return;
78  }
79 
80  query.Session.CreateTable(tableInfo, temporary);
81 
82  using (var systemContext = query.Direct()) {
83  systemContext.GrantToUserOnTable(tableInfo.TableName, query.User().Name, Privileges.TableAll);
84  }
85  }
A long string in the system.
static int Deveel.Data.Sql.Tables.QueryExtensions.DeleteFrom ( this IQuery  context,
ObjectName  tableName,
SqlQueryExpression  query 
)
inlinestatic

Definition at line 29 of file QueryExtensions.Commands.cs.

29  {
30  return DeleteFrom(context, tableName, query, -1);
31  }
static int DeleteFrom(this IQuery context, ObjectName tableName, SqlQueryExpression query)
static int Deveel.Data.Sql.Tables.QueryExtensions.DeleteFrom ( this IQuery  context,
ObjectName  tableName,
SqlExpression  expression 
)
inlinestatic

Definition at line 33 of file QueryExtensions.Commands.cs.

33  {
34  return DeleteFrom(context, tableName, expression, -1);
35  }
static int DeleteFrom(this IQuery context, ObjectName tableName, SqlQueryExpression query)
static int Deveel.Data.Sql.Tables.QueryExtensions.DeleteFrom ( this IQuery  context,
ObjectName  tableName,
SqlExpression  expression,
int  limit 
)
inlinestatic

Definition at line 37 of file QueryExtensions.Commands.cs.

37  {
38  if (expression is SqlQueryExpression)
39  return context.DeleteFrom(tableName, (SqlQueryExpression)expression, limit);
40 
41  var table = context.GetMutableTable(tableName);
42  if (table == null)
43  throw new ObjectNotFoundException(tableName);
44 
45  var queryExpression = new SqlQueryExpression(new List<SelectColumn> { SelectColumn.Glob("*") });
46  queryExpression.FromClause.AddTable(tableName.Name);
47  queryExpression.WhereExpression = expression;
48 
49  var planExpression = queryExpression.Evaluate(context, null);
50  var plan = (SqlQueryObject)((SqlConstantExpression)planExpression).Value.Value;
51  var deleteSet = plan.QueryPlan.Evaluate(context);
52 
53  return context.DeleteFrom(tableName, deleteSet, limit);
54  }
virtual SqlExpression Evaluate(EvaluateContext context)
When overridden by a derived class, this method evaluates the expression within the provided context...
Represents a column selected to be in the output of a select statement.
Definition: SelectColumn.cs:31
An expression that holds a constant value.
static SelectColumn Glob(string glob)
Creates a special SelectColumn that is used to select all the columns in a table. ...
static int Deveel.Data.Sql.Tables.QueryExtensions.DeleteFrom ( this IQuery  context,
ObjectName  tableName,
SqlQueryExpression  query,
int  limit 
)
inlinestatic

Definition at line 56 of file QueryExtensions.Commands.cs.

56  {
57  IQueryPlanNode plan;
58 
59  try {
60  var planValue = query.EvaluateToConstant(context, null);
61  if (planValue == null)
62  throw new InvalidOperationException();
63 
64  if (!(planValue.Type is QueryType))
65  throw new InvalidOperationException();
66 
67  plan = ((SqlQueryObject)planValue.Value).QueryPlan;
68  } catch (QueryException) {
69  throw;
70  } catch (SecurityException) {
71  throw;
72  } catch (Exception ex) {
73  throw new InvalidOperationException(String.Format("Could not delete from table '{0}': unable to form the delete set.", tableName), ex);
74  }
75 
76  var deleteSet = plan.Evaluate(context);
77  return context.DeleteFrom(tableName, deleteSet, limit);
78  }
A long string in the system.
ITable Evaluate(IRequest context)
A node element of a query plan tree. /summary>
static int Deveel.Data.Sql.Tables.QueryExtensions.DeleteFrom ( this IQuery  context,
ObjectName  tableName,
ITable  deleteSet,
int  limit 
)
inlinestatic

Definition at line 80 of file QueryExtensions.Commands.cs.

80  {
81  if (!context.UserCanDeleteFromTable(tableName))
82  throw new MissingPrivilegesException(context.UserName(), tableName, Privileges.Delete);
83 
84  var table = context.GetMutableTable(tableName);
85  if (table == null)
86  throw new ObjectNotFoundException(tableName);
87 
88  return table.Delete(deleteSet, limit);
89  }
static void Deveel.Data.Sql.Tables.QueryExtensions.DropAllTableConstraints ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 284 of file QueryExtensions.cs.

284  {
285  query.Session.DropAllTableConstraints(tableName);
286  }
static int Deveel.Data.Sql.Tables.QueryExtensions.DropConstraint ( this IQuery  query,
ObjectName  tableName,
string  constraintName 
)
inlinestatic

Definition at line 288 of file QueryExtensions.cs.

288  {
289  return query.Session.DropTableConstraint(tableName, constraintName);
290  }
static bool Deveel.Data.Sql.Tables.QueryExtensions.DropPrimaryKey ( this IQuery  query,
ObjectName  tableName,
string  constraintName 
)
inlinestatic

Definition at line 309 of file QueryExtensions.cs.

309  {
310  return query.Session.DropTablePrimaryKey(tableName, constraintName);
311  }
static void Deveel.Data.Sql.Tables.QueryExtensions.DropTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 156 of file QueryExtensions.cs.

156  {
157  DropTable(query, tableName, false);
158  }
static void DropTable(this IQuery query, ObjectName tableName)
static void Deveel.Data.Sql.Tables.QueryExtensions.DropTable ( this IQuery  query,
ObjectName  tableName,
bool  onlyIfExists 
)
inlinestatic

Definition at line 160 of file QueryExtensions.cs.

160  {
161  query.DropTables(new[] { tableName }, onlyIfExists);
162  }
static void Deveel.Data.Sql.Tables.QueryExtensions.DropTables ( this IQuery  query,
IEnumerable< ObjectName tableNames 
)
inlinestatic

Definition at line 103 of file QueryExtensions.cs.

103  {
104  DropTables(query, tableNames, false);
105  }
static void DropTables(this IQuery query, IEnumerable< ObjectName > tableNames)
static void Deveel.Data.Sql.Tables.QueryExtensions.DropTables ( this IQuery  query,
IEnumerable< ObjectName tableNames,
bool  onlyIfExists 
)
inlinestatic

Definition at line 107 of file QueryExtensions.cs.

107  {
108  var tableNameList = tableNames.ToList();
109  foreach (var tableName in tableNameList) {
110  if (!query.UserCanDropObject(DbObjectType.Table, tableName))
111  throw new MissingPrivilegesException(query.UserName(), tableName, Privileges.Drop);
112  }
113 
114  // Check there are no referential links to any tables being dropped
115  foreach (var tableName in tableNameList) {
116  var refs = query.GetTableImportedForeignKeys(tableName);
117 
118  foreach (var reference in refs) {
119  // If the key table isn't being dropped then error
120  if (!tableNameList.Contains(reference.TableName)) {
121  throw new ConstraintViolationException(SqlModelErrorCodes.DropTableViolation,
122  String.Format("Constraint violation ({0}) dropping table '{1}' because of referential link from '{2}'",
123  reference.ConstraintName, tableName, reference.TableName));
124  }
125  }
126  }
127 
128  // If the 'only if exists' flag is false, we need to check tables to drop
129  // exist first.
130  if (!onlyIfExists) {
131  // For each table to drop.
132  foreach (var tableName in tableNameList) {
133  // If table doesn't exist, throw an error
134  if (!query.TableExists(tableName)) {
135  throw new InvalidOperationException(String.Format("The table '{0}' does not exist and cannot be dropped.",
136  tableName));
137  }
138  }
139  }
140 
141  foreach (var tname in tableNameList) {
142  // Does the table already exist?
143  if (query.TableExists(tname)) {
144  // Drop table in the transaction
145  query.DropObject(DbObjectType.Table, tname);
146 
147  // Revoke all the grants on the table
148  query.RevokeAllGrantsOnTable(tname);
149 
150  // Drop all constraints from the schema
151  query.DropAllTableConstraints(tname);
152  }
153  }
154  }
A long string in the system.
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static ITable Deveel.Data.Sql.Tables.QueryExtensions.GetCachedTable ( this IQuery  query,
string  cacheKey 
)
inlinestatic

Definition at line 189 of file QueryExtensions.cs.

189  {
190  var tableCache = query.TableCache();
191  if (tableCache == null)
192  return null;
193 
194  object obj;
195  if (!tableCache.TryGet(cacheKey, out obj))
196  return null;
197 
198  return obj as ITable;
199  }
static IMutableTable Deveel.Data.Sql.Tables.QueryExtensions.GetMutableTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 185 of file QueryExtensions.cs.

185  {
186  return query.GetTable(tableName) as IMutableTable;
187  }
static ITable Deveel.Data.Sql.Tables.QueryExtensions.GetTable ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 172 of file QueryExtensions.cs.

172  {
173  var table = query.GetCachedTable(tableName.FullName) as ITable;
174  if (table == null) {
175  table = query.Session.GetTable(tableName);
176  if (table != null) {
177  table = new UserContextTable(query, table);
178  query.CacheTable(tableName.FullName, table);
179  }
180  }
181 
182  return table;
183  }
static ConstraintInfo [] Deveel.Data.Sql.Tables.QueryExtensions.GetTableCheckExpressions ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 317 of file QueryExtensions.cs.

317  {
318  return query.Session.QueryTableCheckExpressions(tableName);
319  }
static ConstraintInfo [] Deveel.Data.Sql.Tables.QueryExtensions.GetTableForeignKeys ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 325 of file QueryExtensions.cs.

325  {
326  return query.Session.QueryTableForeignKeys(tableName);
327  }
static ConstraintInfo [] Deveel.Data.Sql.Tables.QueryExtensions.GetTableImportedForeignKeys ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 321 of file QueryExtensions.cs.

321  {
322  return query.Session.QueryTableImportedForeignKeys(tableName);
323  }
static ConstraintInfo Deveel.Data.Sql.Tables.QueryExtensions.GetTablePrimaryKey ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 329 of file QueryExtensions.cs.

329  {
330  return query.Session.QueryTablePrimaryKey(tableName);
331  }
static ITableQueryInfo Deveel.Data.Sql.Tables.QueryExtensions.GetTableQueryInfo ( this IQuery  context,
ObjectName  tableName,
ObjectName  alias 
)
inlinestatic

Definition at line 87 of file QueryExtensions.cs.

87  {
88  return context.Session.GetTableQueryInfo(tableName, alias);
89  }
static ConstraintInfo [] Deveel.Data.Sql.Tables.QueryExtensions.GetTableUniqueKeys ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 333 of file QueryExtensions.cs.

333  {
334  return query.Session.QueryTableUniqueKeys(tableName);
335  }
static void Deveel.Data.Sql.Tables.QueryExtensions.InsertIntoTable ( this IQuery  context,
ObjectName  tableName,
IEnumerable< SqlAssignExpression assignments 
)
inlinestatic

Definition at line 111 of file QueryExtensions.Commands.cs.

111  {
112  var columnNames =
113  assignments.Select(x => x.ReferenceExpression)
114  .Cast<SqlReferenceExpression>()
115  .Select(x => x.ReferenceName.Name).ToArray();
116  if (!context.UserCanInsertIntoTable(tableName, columnNames))
117  throw new MissingPrivilegesException(context.UserName(), tableName, Privileges.Insert);
118 
119  var table = context.GetMutableTable(tableName);
120  if (table == null)
121  throw new ObjectNotFoundException(tableName);
122 
123  var row = table.NewRow();
124  foreach (var expression in assignments) {
125  row.EvaluateAssignment(expression, context);
126  }
127 
128  table.AddRow(row);
129  }
An expression that references an object within a context.
static int Deveel.Data.Sql.Tables.QueryExtensions.InsertIntoTable ( this IQuery  context,
ObjectName  tableName,
IEnumerable< SqlAssignExpression[]>  assignments 
)
inlinestatic

Definition at line 131 of file QueryExtensions.Commands.cs.

131  {
132  int insertCount = 0;
133 
134  foreach (var assignment in assignments) {
135  context.InsertIntoTable(tableName, assignment);
136  insertCount++;
137  }
138 
139  return insertCount;
140  }
static ObjectName Deveel.Data.Sql.Tables.QueryExtensions.ResolveTableName ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 30 of file QueryExtensions.cs.

30  {
31  return query.Session.ResolveTableName(tableName);
32  }
static ObjectName Deveel.Data.Sql.Tables.QueryExtensions.ResolveTableName ( this IQuery  query,
string  name 
)
inlinestatic

Definition at line 34 of file QueryExtensions.cs.

34  {
35  var schema = query.CurrentSchema();
36  if (String.IsNullOrEmpty(schema))
37  throw new InvalidOperationException("Default schema not specified in the query.");
38 
39  var objSchemaName = query.ResolveSchemaName(schema);
40  if (objSchemaName == null)
41  throw new InvalidOperationException(
42  String.Format("The default schema of the session '{0}' is not defined in the database.", schema));
43 
44  var objName = ObjectName.Parse(name);
45  if (objName.Parent == null)
46  objName = new ObjectName(objSchemaName, objName.Name);
47 
48  return query.ResolveTableName(objName);
49  }
A long string in the system.
static ICache Deveel.Data.Sql.Tables.QueryExtensions.TableCache ( this IQuery  query)
inlinestaticprivate

Definition at line 168 of file QueryExtensions.cs.

168  {
169  return query.Context.ResolveService<ICache>("TableCache");
170  }
Provides a contract to access a caching system.
Definition: ICache.cs:25
static bool Deveel.Data.Sql.Tables.QueryExtensions.TableExists ( this IQuery  query,
ObjectName  tableName 
)
inlinestatic

Definition at line 51 of file QueryExtensions.cs.

51  {
52  return query.ObjectExists(DbObjectType.Table, tableName);
53  }
DbObjectType
The kind of objects that can be handled by a database system and its managers
Definition: DbObjectType.cs:27
static int Deveel.Data.Sql.Tables.QueryExtensions.UpdateTable ( this IQuery  context,
ObjectName  tableName,
IQueryPlanNode  queryPlan,
IEnumerable< SqlAssignExpression assignments,
int  limit 
)
inlinestatic

Definition at line 91 of file QueryExtensions.Commands.cs.

92  {
93  var columnNames = assignments.Select(x => x.ReferenceExpression)
94  .Cast<SqlReferenceExpression>()
95  .Select(x => x.ReferenceName.Name).ToArray();
96 
97  if (!context.UserCanUpdateTable(tableName, columnNames))
98  throw new MissingPrivilegesException(context.UserName(), tableName, Privileges.Update);
99 
100  if (!context.UserCanSelectFromPlan(queryPlan))
101  throw new InvalidOperationException();
102 
103  var table = context.GetMutableTable(tableName);
104  if (table == null)
105  throw new ObjectNotFoundException(tableName);
106 
107  var updateSet = queryPlan.Evaluate(context);
108  return table.Update(context, updateSet, assignments, limit);
109  }
An expression that references an object within a context.
ITable Evaluate(IRequest context)

The documentation for this class was generated from the following files: