DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
RequestExtensions.cs
Go to the documentation of this file.
1 using System;
2 
3 using Deveel.Data.Security;
5 using Deveel.Data.Sql.Query;
6 
7 namespace Deveel.Data.Sql.Cursors {
8  public static class RequestExtensions {
9  public static void DeclareCursor(this IRequest context, CursorInfo cursorInfo) {
10  var queryPlan = context.Context.QueryPlanner().PlanQuery(new QueryInfo(context, cursorInfo.QueryExpression));
11  var selectedTables = queryPlan.DiscoverTableNames();
12  foreach (var tableName in selectedTables) {
13  if (!context.Query.UserCanSelectFromTable(tableName))
14  throw new MissingPrivilegesException(context.Query.UserName(), tableName, Privileges.Select);
15  }
16 
17  context.Context.DeclareCursor(cursorInfo);
18  }
19 
20  public static void DeclareCursor(this IRequest context, string cursorName, SqlQueryExpression query) {
21  DeclareCursor(context, cursorName, (CursorFlags)0, query);
22  }
23 
24  public static void DeclareCursor(this IRequest context, string cursorName, CursorFlags flags, SqlQueryExpression query) {
25  context.DeclareCursor(new CursorInfo(cursorName, flags, query));
26  }
27 
28  public static void DeclareInsensitiveCursor(this IRequest context, string cursorName, SqlQueryExpression query) {
29  DeclareInsensitiveCursor(context, cursorName, query, false);
30  }
31 
32  public static void DeclareInsensitiveCursor(this IRequest context, string cursorName, SqlQueryExpression query, bool withScroll) {
33  var flags = CursorFlags.Insensitive;
34  if (withScroll)
35  flags |= CursorFlags.Scroll;
36 
37  context.DeclareCursor(cursorName, flags, query);
38  }
39 
40  public static bool CursorExists(this IRequest query, string cursorName) {
41  return query.Context.CursorExists(cursorName);
42  }
43 
44  public static bool DropCursor(this IRequest query, string cursorName) {
45  return query.Context.DropCursor(cursorName);
46  }
47 
48  public static Cursor FindCursor(this IRequest query, string cursorName) {
49  return query.Context.FindCursor(cursorName);
50  }
51 
52  public static bool OpenCursor(this IRequest query, string cursorName, params SqlExpression[] args) {
53  return query.Context.OpenCursor(query, cursorName, args);
54  }
55 
56  public static bool CloseCursor(this IRequest query, string cursorName) {
57  return query.Context.CloseCursor(cursorName);
58  }
59 
60  }
61 }
static Cursor FindCursor(this IRequest query, string cursorName)
static void DeclareInsensitiveCursor(this IRequest context, string cursorName, SqlQueryExpression query)
static void DeclareCursor(this IRequest context, CursorInfo cursorInfo)
SqlQueryExpression QueryExpression
Definition: CursorInfo.cs:59
static bool CursorExists(this IRequest query, string cursorName)
static bool CloseCursor(this IRequest query, string cursorName)
static void DeclareCursor(this IRequest context, string cursorName, SqlQueryExpression query)
static void DeclareCursor(this IRequest context, string cursorName, CursorFlags flags, SqlQueryExpression query)
static bool OpenCursor(this IRequest query, string cursorName, params SqlExpression[] args)
Defines the base class for instances that represent SQL expression tree nodes.
static void DeclareInsensitiveCursor(this IRequest context, string cursorName, SqlQueryExpression query, bool withScroll)
static bool DropCursor(this IRequest query, string cursorName)