Exemplo n.º 1
0
        public override object InternalExecute(Program program, object[] arguments)
        {
            Schema.Object objectValue = null;

                        #if NILPROPOGATION
            if (arguments[0] == null)
            {
                return(null);
            }
            else
                        #endif
            {
                if (Operator.Operands[0].DataType.Is(program.DataTypes.SystemString))
                {
                    objectValue = program.Catalog.Objects[(string)arguments[0]];
                }
                else if (Operator.Operands[0].DataType.Is(program.DataTypes.SystemName))
                {
                    objectValue = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[0]);
                }
                else
                {
                    objectValue = program.Catalog.Objects[(int)arguments[0]];
                }
                return(MetaData.GetTag(objectValue.MetaData, (string)arguments[1], (string)arguments[2]));
            }
        }
Exemplo n.º 2
0
        protected Schema.Catalog _catalog;         // main catalog where all referenced objects can be found

        protected virtual void Describe()
        {
            _catalog = _process.Catalog;
            Schema.Object objectValue = null;
            if (Parser.IsValidQualifiedIdentifier(_seed.Query))
            {
                objectValue = Compiler.ResolveCatalogIdentifier(_program.Plan, _seed.Query, false);
            }

            if (objectValue != null)
            {
                _elaborableTableVarName = objectValue.Name;
                _elaborableCatalog      = _process.Catalog;
            }
            else
            {
                IServerExpressionPlan plan = ((IServerProcess)_process).PrepareExpression(String.Format(@"select {0}{1}", _seed.Query, _seed.Query.IndexOf(Keywords.Capabilities) > 0 || !_seed.Elaborate ? "" : String.Format(" {0} {{ elaborable }}", Keywords.Capabilities)), null);
                try
                {
                    _elaborableTableVarName = plan.TableVar.Name;
                    _elaborableCatalog      = plan.Catalog;
                }
                finally
                {
                    ((IServerProcess)_process).UnprepareExpression(plan);
                }
            }
        }
Exemplo n.º 3
0
 protected override void Validate(Schema.Object objectValue)
 {
     base.Validate(objectValue);
     if (_insensitiveIndex.Contains(objectValue.Name))
     {
         throw new SchemaException(SchemaException.Codes.DuplicateObjectName, objectValue.Name);
     }
 }
Exemplo n.º 4
0
 public override object InternalExecute(Program program, object[] arguments)
 {
     lock (program.Catalog)
     {
         Schema.Object objectValue = Compiler.ResolveCatalogIdentifier(program.Plan, (string)arguments[0], false);
         return(objectValue is Schema.Role);
     }
 }
Exemplo n.º 5
0
 public void CheckDataType(Plan plan, Schema.ScalarType expectedDataType)
 {
     Schema.Object dataTypeObject = Compiler.ResolveCatalogIdentifier(plan, DocumentType.DataType, true);
     if
     (
         !(dataTypeObject is Schema.ScalarType) ||
         (
             (expectedDataType != plan.DataTypes.SystemBinary) &&
             !((Schema.ScalarType)dataTypeObject).Is(expectedDataType)
         )
     )
     {
         throw new CompilerException(CompilerException.Codes.ExpressionTypeMismatch, dataTypeObject.Name, expectedDataType.Name);
     }
 }
Exemplo n.º 6
0
 protected override void Removing(Schema.Object objectValue, int index)
 {
     _insensitiveIndex.Remove(objectValue.Name);
     base.Removing(objectValue, index);
 }
Exemplo n.º 7
0
 protected override void Adding(Schema.Object objectValue, int index)
 {
     base.Adding(objectValue, index);
     _insensitiveIndex.Add(objectValue.Name, objectValue);
 }
Exemplo n.º 8
0
        public override void DetermineDataType(Plan plan)
        {
            DetermineModifiers(plan);
            _dataType       = new Schema.TableType();
            _tableVar       = new Schema.ResultTableVar(this);
            _tableVar.Owner = plan.User;
            _tableVar.InheritMetaData(SourceTableVar.MetaData);
            CopyTableVarColumns(SourceTableVar.Columns);
            _extendColumnOffset = TableVar.Columns.Count;

            // This structure will track key columns as a set of sets, and any extended columns that are equivalent to them
            Dictionary <string, Schema.Key> keyColumns = new Dictionary <string, Schema.Key>();

            foreach (Schema.TableVarColumn tableVarColumn in TableVar.Columns)
            {
                if (SourceTableVar.Keys.IsKeyColumnName(tableVarColumn.Name) && !keyColumns.ContainsKey(tableVarColumn.Name))
                {
                    keyColumns.Add(tableVarColumn.Name, new Schema.Key(new Schema.TableVarColumn[] { tableVarColumn }));
                }
            }

            ApplicationTransaction transaction = null;

            if (plan.ApplicationTransactionID != Guid.Empty)
            {
                transaction = plan.GetApplicationTransaction();
            }
            try
            {
                if (transaction != null)
                {
                    transaction.PushLookup();
                }
                try
                {
                    plan.PushCursorContext(new CursorContext(CursorType.Dynamic, CursorCapability.Navigable, CursorIsolation.None));
                    try
                    {
                        plan.EnterRowContext();
                        try
                        {
                            plan.Symbols.Push(new Symbol(String.Empty, SourceTableType.RowType));
                            try
                            {
                                // Add a column for each expression
                                PlanNode planNode;
                                Schema.TableVarColumn newColumn;
                                foreach (NamedColumnExpression column in _expressions)
                                {
                                    newColumn = new Schema.TableVarColumn(new Schema.Column(column.ColumnAlias, plan.DataTypes.SystemScalar));
                                    plan.PushCreationObject(newColumn);
                                    try
                                    {
                                        planNode = Compiler.CompileExpression(plan, column.Expression);
                                    }
                                    finally
                                    {
                                        plan.PopCreationObject();
                                    }

                                    bool isChangeRemotable = true;
                                    if (newColumn.HasDependencies())
                                    {
                                        for (int index = 0; index < newColumn.Dependencies.Count; index++)
                                        {
                                            Schema.Object objectValue = newColumn.Dependencies.ResolveObject(plan.CatalogDeviceSession, index);
                                            isChangeRemotable = isChangeRemotable && objectValue.IsRemotable;
                                            plan.AttachDependency(objectValue);
                                        }
                                    }

                                    bool isUpdatable = planNode is TableNode || planNode is ExtractRowNode;

                                    newColumn =
                                        new Schema.TableVarColumn
                                        (
                                            new Schema.Column(column.ColumnAlias, planNode.DataType),
                                            column.MetaData,
                                            isUpdatable ? Schema.TableVarColumnType.Stored : Schema.TableVarColumnType.Virtual
                                        );

                                    newColumn.IsNilable          = planNode.IsNilable;
                                    newColumn.IsChangeRemotable  = isChangeRemotable;
                                    newColumn.IsDefaultRemotable = isChangeRemotable;

                                    DataType.Columns.Add(newColumn.Column);
                                    TableVar.Columns.Add(newColumn);

                                    string columnName = String.Empty;
                                    if (IsColumnReferencing(planNode, ref columnName))
                                    {
                                        // TODO: In theory we could allow updatability through an IsColumnReferencing add column as well
                                        Schema.TableVarColumn referencedColumn = TableVar.Columns[columnName];
                                        if (SourceTableVar.Keys.IsKeyColumnName(referencedColumn.Name))
                                        {
                                            Schema.Key key;
                                            if (keyColumns.TryGetValue(referencedColumn.Name, out key))
                                            {
                                                key.Columns.Add(newColumn);
                                            }
                                            else
                                            {
                                                keyColumns.Add(referencedColumn.Name, new Schema.Key(new Schema.TableVarColumn[] { newColumn }));
                                            }
                                        }
                                    }

                                    Nodes.Add(planNode);
                                }

                                DetermineRemotable(plan);
                            }
                            finally
                            {
                                plan.Symbols.Pop();
                            }
                        }
                        finally
                        {
                            plan.ExitRowContext();
                        }
                    }
                    finally
                    {
                        plan.PopCursorContext();
                    }
                }
                finally
                {
                    if (transaction != null)
                    {
                        transaction.PopLookup();
                    }
                }
            }
            finally
            {
                if (transaction != null)
                {
                    Monitor.Exit(transaction);
                }
            }

            foreach (Schema.Key key in SourceTableVar.Keys)
            {
                // Seed the result key set with the empty set
                Schema.Keys resultKeys = new Schema.Keys();
                resultKeys.Add(new Schema.Key());

                foreach (Schema.TableVarColumn column in key.Columns)
                {
                    resultKeys = KeyProduct(resultKeys, keyColumns[column.Name]);
                }

                foreach (Schema.Key resultKey in resultKeys)
                {
                    resultKey.IsSparse    = key.IsSparse;
                    resultKey.IsInherited = true;
                    resultKey.MergeMetaData(key.MetaData);
                    TableVar.Keys.Add(resultKey);
                }
            }

            CopyOrders(SourceTableVar.Orders);
            if (SourceNode.Order != null)
            {
                Order = CopyOrder(SourceNode.Order);
            }

                        #if UseReferenceDerivation
                        #if UseElaborable
            if (plan.CursorContext.CursorCapabilities.HasFlag(CursorCapability.Elaborable))
                        #endif
            CopyReferences(plan, SourceTableVar);
                        #endif
        }
Exemplo n.º 9
0
        public static SettingsList GetClasses()
        {
            var classes = new SettingsList();

            Type[] types = typeof(DAERegister).Assembly.GetTypes();

            foreach (Type type in types)
            {
                // Nodes
                if (type.IsSubclassOf(typeof(InstructionNodeBase)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Object.Unqualify(type.Name)),
                                                 type.AssemblyQualifiedName));
                }

                // Devices
                if (type.IsSubclassOf(typeof(Schema.Device)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Object.Unqualify(type.Name)),
                                                 type.AssemblyQualifiedName));
                }

                // Conveyors
                if (type.IsSubclassOf(typeof(Conveyor)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Object.Unqualify(type.Name)),
                                                 type.AssemblyQualifiedName));
                }

                // DeviceOperator
                if (type.IsSubclassOf(typeof(DeviceOperator)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Object.Unqualify(type.Name)),
                                                 type.AssemblyQualifiedName));
                }

                // DeviceScalarType
                if (type.IsSubclassOf(typeof(DeviceScalarType)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Object.Unqualify(type.Name)),
                                                 type.AssemblyQualifiedName));
                }

                // ConnectionStringBuilder
                if (type.IsSubclassOf(typeof(ConnectionStringBuilder)))
                {
                    classes.Add(new SettingsItem(String.Format("{0}.{1}", D4ClassDefinitionNameSpace, Object.Unqualify(type.Name)),
                                                 type.AssemblyQualifiedName));
                }
            }

            return(classes);
        }