Esempio n. 1
0
        public static object Evaluate(Program program, string expression, Schema.TableVar tableVar, DataParams dataParams)
        {
            IServerExpressionPlan plan = ((IServerProcess)program.ServerProcess).PrepareExpression(expression, dataParams);

            try
            {
                plan.CheckCompiled();

                IServerCursor cursor = plan.Open(dataParams);
                try
                {
                    NativeTable nativeTable = new NativeTable(program.ValueManager, tableVar);
                    while (cursor.Next())
                    {
                        using (IRow row = cursor.Select())
                        {
                            nativeTable.Insert(program.ValueManager, row);
                        }
                    }
                    return(new TableValue(program.ValueManager, nativeTable.TableType, nativeTable));
                }
                finally
                {
                    plan.Close(cursor);
                }
            }
            finally
            {
                ((IServerProcess)program.ServerProcess).UnprepareExpression(plan);
            }
        }
Esempio n. 2
0
 public void LoadTable(ServerProcess process, Schema.TableVar tableVar)
 {
     lock (_loadedTables)
     {
         if (!IsLoaded(tableVar))
         {
             _loadedTables.Add(tableVar);
             if (File.Exists(GetTableVarFileName(tableVar)))
             {
                 using (FileStream stream = new FileStream(GetTableVarFileName(tableVar), FileMode.Open, FileAccess.Read))
                 {
                     NativeTable nativeTable = Tables[tableVar];
                     while (stream.Position < stream.Length)
                     {
                         int    length   = StreamUtility.ReadInteger(stream);
                         byte[] rowValue = new byte[length];
                         stream.Read(rowValue, 0, rowValue.Length);
                         IRow row = (IRow)DataValue.FromPhysical(process.ValueManager, nativeTable.RowType, rowValue, 0);
                         try
                         {
                             nativeTable.Insert(process.ValueManager, row);
                         }
                         finally
                         {
                             row.Dispose();
                         }
                     }
                 }
             }
         }
     }
 }
Esempio n. 3
0
 public CatalogHeader(Schema.TableVar tableVar, NativeTable nativeTable, long timeStamp, CatalogCacheLevel cacheLevel) : base()
 {
     _tableVar    = tableVar;
     _nativeTable = nativeTable;
     TimeStamp    = timeStamp;
     _cacheLevel  = cacheLevel;
 }
Esempio n. 4
0
        private void PopulateLoadedLibraries(Program program, NativeTable nativeTable, Row row)
        {
            List <string> libraryNames = ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SelectLoadedLibraries();

            for (int index = 0; index < libraryNames.Count; index++)
            {
                row[0] = libraryNames[index];
                nativeTable.Insert(program.ValueManager, row);
            }
        }
Esempio n. 5
0
 private void PopulateRegisteredAssemblies(Program program, NativeTable nativeTable, Row row)
 {
     foreach (RegisteredAssembly assembly in program.Catalog.ClassLoader.Assemblies)
     {
         row[0] = assembly.Name.ToString();
         row[1] = assembly.Library.Name;
         row[2] = assembly.Assembly.Location;
         nativeTable.Insert(program.ValueManager, row);
     }
 }
Esempio n. 6
0
        private void PopulateConnections(Program program, NativeTable nativeTable, Row row)
        {
/*
 *                      foreach (ServerConnection LConnection in AProgram.ServerProcess.ServerSession.Server.Connections)
 *                      {
 *                              ARow[0] = LConnection.ConnectionName;
 *                              ARow[1] = LConnection.HostName;
 *                              ANativeTable.Insert(AProgram.ValueManager, ARow);
 *                      }
 */
        }
Esempio n. 7
0
 private void PopulateRegisteredClasses(Program program, NativeTable nativeTable, Row row)
 {
     foreach (RegisteredClass classValue in program.Catalog.ClassLoader.Classes)
     {
         row[0] = classValue.Name;
         row[1] = classValue.Library.Name;
         row[2] = classValue.Assembly.Name.ToString();
         row[3] = classValue.ClassName;
         nativeTable.Insert(program.ValueManager, row);
     }
 }
Esempio n. 8
0
 private void PopulateApplicationTransactions(Program program, NativeTable nativeTable, Row row)
 {
     lock (program.ServerProcess.ServerSession.Server.ATDevice.ApplicationTransactions.SyncRoot)
     {
         foreach (ApplicationTransaction.ApplicationTransaction transaction in program.ServerProcess.ServerSession.Server.ATDevice.ApplicationTransactions.Values)
         {
             row[0] = transaction.ID;
             row[1] = transaction.Session.SessionID;
             row[2] = transaction.Device.Name;
             nativeTable.Insert(program.ValueManager, row);
         }
     }
 }
Esempio n. 9
0
 private void PopulateSessionCatalogObjects(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         foreach (Schema.SessionObject objectValue in session.SessionObjects)
         {
             row[0] = session.SessionID;
             row[1] = objectValue.Name;
             row[2] = objectValue.GlobalName;
             nativeTable.Insert(program.ValueManager, row);
         }
     }
 }
Esempio n. 10
0
 private void PopulateLibraryRequisites(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Library library in program.Catalog.Libraries)
     {
         foreach (LibraryReference reference in library.Libraries)
         {
             row[0] = library.Name;
             row[1] = reference.Name;
             row[2] = reference.Version;
             nativeTable.Insert(program.ValueManager, row);
         }
     }
 }
Esempio n. 11
0
 private void PopulateLibraryFiles(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Library library in program.Catalog.Libraries)
     {
         foreach (Schema.FileReference reference in library.Files)
         {
             row[0] = library.Name;
             row[1] = reference.FileName;
             row[2] = reference.IsAssembly;
             nativeTable.Insert(program.ValueManager, row);
         }
     }
 }
Esempio n. 12
0
 private void PopulateLibraries(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Library library in program.Catalog.Libraries)
     {
         row[0] = library.Name;
         row[1] = library.Directory;
         row[2] = library.Version;
         row[3] = library.DefaultDeviceName;
         row[4] = true;                 //AProgram.ServerProcess.ServerSession.Server.CanLoadLibrary(LLibrary.Name);
         row[5] = library.IsSuspect;
         row[6] = library.SuspectReason;
         nativeTable.Insert(program.ValueManager, row);
     }
 }
Esempio n. 13
0
 private void PopulateDeviceSessions(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         foreach (ServerProcess process in session.Processes)
         {
             foreach (DeviceSession deviceSession in process.DeviceSessions)
             {
                 row[0] = deviceSession.Device.Name;
                 row[1] = process.ProcessID;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 14
0
 private void PopulatePlans(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         foreach (ServerProcess process in session.Processes)
         {
             foreach (ServerPlan plan in process.Plans)
             {
                 row[0] = plan.ID;
                 row[1] = process.ProcessID;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 15
0
 private void PopulateScripts(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         foreach (ServerProcess process in session.Processes)
         {
             foreach (ServerScript script in process.Scripts)
             {
                 row[0] = script.GetHashCode();
                 row[1] = process.ProcessID;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 16
0
 private void PopulateRemoteSessions(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         foreach (ServerProcess process in session.Processes)
         {
             foreach (RemoteSession remoteSession in process.RemoteSessions)
             {
                 row[0] = remoteSession.ServerLink.Name;
                 row[1] = process.ProcessID;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 17
0
 private void PopulateScalarTypeParentScalarTypes(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Schema.Object localObject in program.Catalog)
     {
         if (localObject is Schema.ScalarType)
         {
             foreach (Schema.ScalarType parentScalarType in ((Schema.ScalarType)localObject).ParentTypes)
             {
                 row[0] = localObject.Name;
                 row[1] = parentScalarType.Name;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 18
0
 private void PopulateLibraryFileEnvironments(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Library library in program.Catalog.Libraries)
     {
         foreach (Schema.FileReference reference in library.Files)
         {
             foreach (string environment in reference.Environments)
             {
                 row[0] = library.Name;
                 row[1] = reference.FileName;
                 row[2] = environment;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 19
0
 private void PopulateScalarTypeExplicitCastFunctions(Program AProgram, NativeTable ANativeTable, Row ARow)
 {
     foreach (Schema.Object LObject in AProgram.Catalog)
     {
         if (LObject is Schema.ScalarType)
         {
             Schema.ScalarType LScalarType = (Schema.ScalarType)LObject;
             foreach (Schema.Operator LOperator in LScalarType.ExplicitCastOperators)
             {
                 ARow[0] = LScalarType.Name;
                 ARow[1] = LOperator.Name;
                 ANativeTable.Insert(AProgram.ValueManager, ARow);
             }
         }
     }
 }
Esempio n. 20
0
 private void PopulateServerLinkUsers(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Schema.Object objectValue in program.Catalog)
     {
         Schema.ServerLink serverLink = objectValue as Schema.ServerLink;
         if (serverLink != null)
         {
             foreach (ServerLinkUser linkUser in serverLink.Users.Values)
             {
                 row[0] = linkUser.UserID;
                 row[1] = serverLink.Name;
                 row[2] = linkUser.ServerLinkUserID;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 21
0
        protected override void InternalInsertRow(Program program, Schema.TableVar table, IRow row, BitArray valueFlags)
        {
            NativeTable localTable = GetTables(table.Scope)[table];

            if ((Device.MaxRowCount >= 0) && (localTable.RowCount >= Device.MaxRowCount) && (!InTransaction || !ServerProcess.CurrentTransaction.InRollback))
            {
                throw new DeviceException(DeviceException.Codes.MaxRowCountExceeded, Device.MaxRowCount.ToString(), table.DisplayName, Device.DisplayName);
            }

            localTable.Insert(ServerProcess.ValueManager, row);

                        #if USEMEMORYDEVICETRANSACTIONS
            if (InTransaction && !ServerProcess.NonLogged && !ServerProcess.CurrentTransaction.InRollback)
            {
                Transactions.CurrentTransaction().Operations.Add(new DeleteOperation(ATable, (IRow)ARow.Copy()));
            }
                        #endif
        }
Esempio n. 22
0
 private void PopulateServerSettings(Program program, NativeTable nativeTable, Row row)
 {
     DAE.Server.Server server = (DAE.Server.Server)program.ServerProcess.ServerSession.Server;
     row[0]  = server.Name;
     row[1]  = GetType().Assembly.GetName().Version.ToString();
     row[2]  = server.LogErrors;
     row[3]  = server.Catalog.TimeStamp;
     row[4]  = server.CacheTimeStamp;
     row[5]  = server.PlanCacheTimeStamp;
     row[6]  = server.DerivationTimeStamp;
     row[7]  = server.InstanceDirectory;
     row[8]  = server.LibraryDirectory;
     row[9]  = server.IsEngine;
     row[10] = server.MaxConcurrentProcesses;
     row[11] = server.ProcessWaitTimeout;
     row[12] = server.ProcessTerminationTimeout;
     row[13] = server.PlanCache.Size;
     nativeTable.Insert(program.ValueManager, row);
 }
Esempio n. 23
0
 private void PopulateProcesses(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         foreach (ServerProcess process in session.Processes)
         {
             row[0] = process.ProcessID;
             row[1] = session.SessionID;
             row[2] = process.DefaultIsolationLevel.ToString();
             row[3] = process.UseDTC;
             row[4] = process.UseImplicitTransactions;
             row[5] = process.ProcessInfo.Language.ToString();
             row[6] = process.MaxStackDepth;
             row[7] = process.MaxCallDepth;
             row[8] = process.ExecutingThread != null;
             nativeTable.Insert(program.ValueManager, row);
         }
     }
 }
Esempio n. 24
0
 private void PopulateServerLinks(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Schema.Object objectValue in program.Catalog)
     {
         Schema.ServerLink serverLink = objectValue as Schema.ServerLink;
         if (serverLink != null)
         {
             row[0] = serverLink.ID;
             row[1] = serverLink.Name;
             row[2] = serverLink.Library.Name;
             row[3] = serverLink.Owner.ID;
             row[4] = serverLink.IsSystem;
             row[5] = serverLink.IsGenerated;
             row[6] = serverLink.HostName;
             row[7] = serverLink.InstanceName;
             row[8] = serverLink.OverridePortNumber;
             row[9] = serverLink.UseSessionInfo;
             nativeTable.Insert(program.ValueManager, row);
         }
     }
 }
Esempio n. 25
0
 private void PopulateSessions(Program program, NativeTable nativeTable, Row row)
 {
     foreach (ServerSession session in program.ServerProcess.ServerSession.Server.Sessions)
     {
         row[0]  = session.SessionID;
         row[1]  = session.User.ID;
         row[2]  = session.SessionInfo.HostName;
         row[3]  = session.SessionInfo.CatalogCacheName;
         row[4]  = session.SessionInfo.Environment;
         row[5]  = session.CurrentLibrary.Name;
         row[6]  = session.SessionInfo.DefaultIsolationLevel.ToString();
         row[7]  = session.SessionInfo.DefaultUseDTC;
         row[8]  = session.SessionInfo.DefaultUseImplicitTransactions;
         row[9]  = session.SessionInfo.Language.ToString();
         row[10] = session.SessionInfo.FetchCount;
         row[11] = session.SessionInfo.DefaultMaxStackDepth;
         row[12] = session.SessionInfo.DefaultMaxCallDepth;
         row[13] = session.SessionInfo.UsePlanCache;
         row[14] = session.SessionInfo.ShouldEmitIL;
         row[15] = session.SessionInfo.ShouldElaborate;
         nativeTable.Insert(program.ValueManager, row);
     }
 }
Esempio n. 26
0
 private void PopulateLibrarySettings(Program program, NativeTable nativeTable, Row row)
 {
     foreach (Library library in program.Catalog.Libraries)
     {
         if (library.MetaData != null)
         {
                                 #if USEHASHTABLEFORTAGS
             foreach (Tag tag in library.MetaData.Tags)
             {
                                 #else
             Tag tag;
             for (int index = 0; index < library.MetaData.Tags.Count; index++)
             {
                 tag = library.MetaData.Tags[index];
                                 #endif
                 row[0] = library.Name;
                 row[1] = tag.Name;
                 row[2] = tag.Value;
                 nativeTable.Insert(program.ValueManager, row);
             }
         }
     }
 }
Esempio n. 27
0
 private void PopulateLibraryVersions(Program program, NativeTable nativeTable, Row row)
 {
     ((ServerCatalogDeviceSession)program.CatalogDeviceSession).SelectLibraryVersions(program, nativeTable, row);
 }
Esempio n. 28
0
        public static IDataValue NativeValueToDataValue(ServerProcess process, NativeValue nativeValue)
        {
            NativeScalarValue nativeScalar = nativeValue as NativeScalarValue;

            if (nativeScalar != null)
            {
                return(new Scalar(process.ValueManager, (IScalarType)NativeTypeNameToDataType(process.DataTypes, nativeScalar.DataTypeName), nativeScalar.Value));
            }

            NativeListValue nativeList = nativeValue as NativeListValue;

            if (nativeList != null)
            {
                // Create and fill the list
                ListValue list = new ListValue(process.ValueManager, (ListType)NativeValueToDataType(process, nativeValue), nativeList.Elements == null ? null : new NativeList());
                if (nativeList.Elements != null && nativeList.Elements.Length > 0)
                {
                    for (int index = 0; index < nativeList.Elements.Length; index++)
                    {
                        list.Add(NativeValueToDataValue(process, nativeList.Elements[index]));
                    }
                }

                return(list);
            }

            NativeRowValue nativeRow = nativeValue as NativeRowValue;

            if (nativeRow != null)
            {
                Row row = new Row(process.ValueManager, new Schema.RowType(NativeColumnsToColumns(process.DataTypes, nativeRow.Columns)));
                if (nativeRow.Values == null)
                {
                    row.AsNative = null;
                }
                else
                {
                    for (int index = 0; index < nativeRow.Values.Length; index++)
                    {
                        row[index] = NativeValueToDataValue(process, nativeRow.Values[index]);
                    }
                }
                return(row);
            }

            NativeTableValue nativeTable = nativeValue as NativeTableValue;

            if (nativeTable != null)
            {
                NativeTable internalTable = new NativeTable(process.ValueManager, NativeTableToTableVar(process, nativeTable));
                TableValue  table         = new TableValue(process.ValueManager, internalTable.TableType, internalTable);
                if (nativeTable.Rows == null)
                {
                    table.AsNative = null;
                }
                else
                {
                    bool[] valueTypes = new bool[internalTable.TableType.Columns.Count];
                    for (int index = 0; index < internalTable.TableType.Columns.Count; index++)
                    {
                        valueTypes[index] = internalTable.TableType.Columns[index].DataType is IScalarType;
                    }

                    for (int index = 0; index < nativeTable.Rows.Length; index++)
                    {
                        Row row = new Row(process.ValueManager, internalTable.RowType);
                        try
                        {
                            for (int columnIndex = 0; columnIndex < nativeTable.Rows[index].Length; columnIndex++)
                            {
                                if (valueTypes[columnIndex])
                                {
                                    row[columnIndex] = nativeTable.Rows[index][columnIndex];
                                }
                                else
                                {
                                    row[columnIndex] = NativeValueToDataValue(process, (NativeValue)nativeTable.Rows[index][columnIndex]);
                                }
                            }

                            internalTable.Insert(process.ValueManager, row);
                        }
                        catch (Exception)
                        {
                            row.Dispose();
                            throw;
                        }
                    }
                }
                return(table);
            }

            throw new NotSupportedException(String.Format("Unknown native value type: \"{0}\".", nativeValue.GetType().Name));
        }
Esempio n. 29
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());
     }
 }