Esempio n. 1
0
        public virtual NativeTables GetTables(Schema.TableVarScope scope)
        {
            switch (scope)
            {
            case Schema.TableVarScope.Process: return(_tables == null ? _tables = new NativeTables() : _tables);

            case Schema.TableVarScope.Session: return(ServerProcess.ServerSession.Tables);

            case Schema.TableVarScope.Database:
            default: return(Device.Tables);
            }
        }
Esempio n. 2
0
        protected NativeTable EnsureNativeTable(Schema.TableVar tableVar)
        {
            if (!tableVar.IsSessionObject && !tableVar.IsATObject)
            {
                tableVar.Scope = (Schema.TableVarScope)Enum.Parse(typeof(Schema.TableVarScope), MetaData.GetTag(tableVar.MetaData, "Storage.Scope", "Database"), false);
            }

            NativeTables tables = GetTables(tableVar.Scope);

            lock (tables)
            {
                int index = tables.IndexOf(tableVar);
                if (index < 0)
                {
                    index = tables.Add(new NativeTable(ServerProcess.ValueManager, tableVar));
                }
                return(tables[index]);
            }
        }
Esempio n. 3
0
 protected override object InternalExecute(Program program, PlanNode planNode)
 {
     if (planNode is BaseTableVarNode)
     {
         MemoryScan scan = new MemoryScan(program, this, (BaseTableVarNode)planNode);
         try
         {
             scan.NativeTable = EnsureNativeTable(((BaseTableVarNode)planNode).TableVar);
             scan.Key         = scan.NativeTable.ClusteredIndex.Key;
             scan.Open();
             return(scan);
         }
         catch
         {
             scan.Dispose();
             throw;
         }
     }
     else if (planNode is OrderNode)
     {
         MemoryScan scan = new MemoryScan(program, this, (BaseTableVarNode)planNode.Nodes[0]);
         try
         {
             scan.NativeTable = EnsureNativeTable(((BaseTableVarNode)planNode.Nodes[0]).TableVar);
             scan.Key         = ((OrderNode)planNode).PhysicalOrder;
             scan.Direction   = ((OrderNode)planNode).ScanDirection;
             scan.Node.Order  = ((OrderNode)planNode).Order;
             scan.Open();
             return(scan);
         }
         catch
         {
             scan.Dispose();
             throw;
         }
     }
     else if (planNode is CreateTableVarBaseNode)
     {
         EnsureNativeTable(((CreateTableVarBaseNode)planNode).GetTableVar());
         return(null);
     }
     else if (planNode is AlterTableNode)
     {
         // TODO: Memory device alter table support
         return(null);
     }
     else if (planNode is DropTableNode)
     {
         Schema.TableVar tableVar = ((DropTableNode)planNode).Table;
         NativeTables    tables   = GetTables(tableVar.Scope);
         lock (tables)
         {
             int tableIndex = tables.IndexOf(tableVar);
             if (tableIndex >= 0)
             {
                 NativeTable nativeTable = tables[tableIndex];
                                         #if USEMEMORYDEVICETRANSACTIONS
                 RemoveTransactionReferences(nativeTable.TableVar);
                                         #endif
                 nativeTable.Drop(program.ValueManager);
                 tables.RemoveAt(tableIndex);
             }
         }
         return(null);
     }
     else
     {
         throw new DeviceException(DeviceException.Codes.InvalidExecuteRequest, Device.Name, planNode.ToString());
     }
 }
Esempio n. 4
0
 protected override void InternalStart(ServerProcess process)
 {
     base.InternalStart(process);
     _tables = new NativeTables();
 }