Beispiel #1
0
        public VariableBind(ObjectName variableName)
        {
            if (variableName == null)
                throw new ArgumentNullException("variableName");

            VariableName = variableName;
        }
        public DropTriggerStatement(ObjectName triggerName)
        {
            if (triggerName == null)
                throw new ArgumentNullException("triggerName");

            TriggerName = triggerName;
        }
        internal ObjectDuplicatedConflictException(ObjectName objectName, string conflictType)
            : base(SystemErrorCodes.DuplicateObjectConflict,
				String.Format("The object '{0}' was {1} twice in transaction.", objectName, conflictType))
        {
            ObjectName = objectName;
            ConflictType = conflictType;
        }
Beispiel #4
0
 private void SetQueryContext(SimpleQuery query)
 {
     _query = query;
     _tableName = ObjectName.Parse(query.TableName.Split('.').Last());
     _table = _schema.FindTable(_tableName);
     _commandBuilder = new CommandBuilder(GetSelectClause(_tableName), _schema.SchemaProvider);
 }
 internal OldNewTableState(ObjectName tableSource, int oldRowIndex, Row newDataRow, bool newMutable)
 {
     TableSource = tableSource;
     OldRowIndex = oldRowIndex;
     NewDataRow = newDataRow;
     IsNewMutable = newMutable;
 }
Beispiel #6
0
        public SortNode(IQueryPlanNode child, ObjectName[] columnNames, bool[] ascending)
            : base(child)
        {
            // How we handle ascending/descending order
            // ----------------------------------------
            // Internally to the database, all columns are naturally ordered in
            // ascending order (start at lowest and end on highest).  When a column
            // is ordered in descending order, a fast way to achieve this is to take
            // the ascending set and reverse it.  This works for single columns,
            // however some thought is required for handling multiple column.  We
            // order columns from RHS to LHS.  If LHS is descending then this will
            // order the RHS incorrectly if we leave as is.  Therefore, we must do
            // some pre-processing that looks ahead on any descending orders and
            // reverses the order of the columns to the right.  This pre-processing
            // is done in the first pass.

            int sz = ascending.Length;
            for (int n = 0; n < sz - 1; ++n) {
                if (!ascending[n]) {    // if descending...
                    // Reverse order of all columns to the right...
                    for (int p = n + 1; p < sz; ++p) {
                        ascending[p] = !ascending[p];
                    }
                }
            }

            ColumnNames = columnNames;
            Ascending = ascending;
        }
 public SimpleSelectNode(IQueryPlanNode child, ObjectName leftVar, Operator op, Expression rightExpression)
     : base(child)
 {
     this.leftVar = leftVar;
     this.op = op;
     this.rightExpression = rightExpression;
 }
        public static DataObject InvokeSystemFunction(this IQueryContext context, string functionName,
			params SqlExpression[] args)
        {
            var resolvedName = new ObjectName(SystemSchema.SchemaName, functionName);
            var invoke = new Invoke(resolvedName, args);
            return context.InvokeFunction(invoke);
        }
        public static void AddForeignKey(this ITransaction transaction, ObjectName table, string[] columns,
			ObjectName refTable, string[] refColumns,
			ForeignKeyAction deleteRule, ForeignKeyAction updateRule, String constraintName)
        {
            AddForeignKey(transaction, table, columns, refTable, refColumns, deleteRule, updateRule,
                ConstraintDeferrability.InitiallyImmediate, constraintName);
        }
        protected override ObjectName NormalizeName(ObjectName functionName)
        {
            if (functionName.Parent == null)
                functionName = new ObjectName(new ObjectName(SchemaName), functionName.Name);

            return base.NormalizeName(functionName);
        }
Beispiel #11
0
        public RenameTriggerAction(ObjectName name)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            Name = name;
        }
Beispiel #12
0
 static SqlPreCommand DropViewIndex(ObjectName viewName, string index)
 {
     return new[]{
          DropIndex(viewName, index),
          DropView(viewName)
     }.Combine(Spacing.Simple);
 }
Beispiel #13
0
        private void SetQueryContext(SimpleQuery query)
        {
            _query = query;
            _tableName = _schema.BuildObjectName(query.TableName);
            _table = _schema.FindTable(_tableName);
            var selectClause = _query.Clauses.OfType<SelectClause>().SingleOrDefault();
            if (selectClause != null)
            {
                if (selectClause.Columns.OfType<AllColumnsSpecialReference>().Any())
                {
                    _columns = ExpandAllColumnsReferences(selectClause.Columns).ToArray();
                }
                else
                {
                    _columns = selectClause.Columns.ToArray();
                }
            }
            else
            {
                _columns = _table.Columns.Select(c => ObjectReference.FromStrings(_table.Schema, _table.ActualName, c.ActualName)).ToArray();
            }

            HandleWithClauses();

            _whereCriteria = _query.Clauses.OfType<WhereClause>().Aggregate(SimpleExpression.Empty,
                                                                            (seed, where) => seed && where.Criteria);
            _havingCriteria = _query.Clauses.OfType<HavingClause>().Aggregate(SimpleExpression.Empty,
                                                                              (seed, having) => seed && having.Criteria);

            _commandBuilder.SetText(GetSelectClause(_tableName));
        }
        private static string BuildMessage(ObjectName objectName)
        {
            if (objectName == null)
                return "Cannot access the object: possibly not enough privileges.";

            return String.Format("Cannot access the '{0}': possibly not enough privileges.", objectName);
        }
        public CreateSequenceStatement(ObjectName sequenceName)
        {
            if (sequenceName == null)
                throw new ArgumentNullException("sequenceName");

            SequenceName = sequenceName;
        }
 public TableQueryInfo(IUserSession session, TableInfo tableInfo, ObjectName tableName, ObjectName aliasName)
 {
     Session = session;
     TableInfo = tableInfo;
     TableName = tableName;
     AliasName = aliasName;
 }
Beispiel #17
0
        public override bool HasPrivileges(DbObjectType objectType, ObjectName objectName, Privileges privileges)
        {
            if (IsSecureAccess)
                return true;

            return base.HasPrivileges(objectType, objectName, privileges);
        }
        public static void AddPrimaryKey(this IQueryContext context, ObjectName tableName, string[] columnNames, string constraintName)
        {
            if (!context.UserCanAlterTable(tableName))
                throw new InvalidOperationException();	// TODO: throw a specialized exception

            context.Session.AddPrimaryKey(tableName, columnNames, ConstraintDeferrability.InitiallyImmediate, constraintName);
        }
Beispiel #19
0
        public int FindByName(ObjectName name)
        {
            if (name == null)
                throw new ArgumentNullException("name");

            if (!transaction.RealTableExists(TypeManager.TypeTableName))
                return -1;

            if (name.Parent == null)
                return -1;

            var typeSchema = Field.String(name.ParentName);
            var typeName = Field.String(name.Name);

            var table = transaction.GetTable(TypeManager.TypeTableName);

            int i = 0;
            foreach (var row in table) {
                if (row.GetValue(1).IsEqualTo(typeSchema) &&
                    row.GetValue(2).IsEqualTo(typeName))
                    return i;

                i++;
            }

            return -1;
        }
Beispiel #20
0
        public IExpressionBuilder Reference(ObjectName referenceName)
        {
            expression = SqlExpression.Reference(referenceName);
            VerifyUnary();

            return this;
        }
        public SubsetColumnTable(Table parent, int[] mapping, ObjectName[] aliases)
            : base(parent)
        {
            int[] reverseColumnMap = new int[Parent.TableInfo.ColumnCount];
            for (int i = 0; i < reverseColumnMap.Length; ++i) {
                reverseColumnMap[i] = -1;
            }

            DataTableInfo parentInfo = Parent.TableInfo;

            subsetTableInfo = new SubsetTableInfo(parentInfo.Name);

            for (int i = 0; i < mapping.Length; ++i) {
                int mapTo = mapping[i];
                DataColumnInfo colInfo = Parent.TableInfo[mapTo];
                var newColumn = subsetTableInfo.NewColumn(aliases[i].Name, colInfo.DataType);
                newColumn.DefaultExpression = colInfo.DefaultExpression;
                newColumn.IsNullable = colInfo.IsNullable;

                subsetTableInfo.AddColumn(colInfo);
                reverseColumnMap[mapTo] = i;
            }

            subsetTableInfo.Setup(mapping, aliases);
            subsetTableInfo.IsReadOnly = true;
        }
Beispiel #22
0
 public ForeignKey(ObjectName detailTable, IEnumerable<string> columns, ObjectName masterTable, IEnumerable<string> masterColumns)
 {
     _columns = new Key(columns);
     _detailTable = detailTable;
     _masterTable = masterTable;
     _masterColumns = new Key(masterColumns);
 }
 public void AddNotificationListener(object token, ObjectName name, ObjectName listener, NotificationFilterCallback filterCallback, object handback)
 {
     using (TemporarySecurityContext tsc = new TemporarySecurityContext(Authorize(token)))
      {
     _server.AddNotificationListener(name, listener, filterCallback, handback);
      }
 }
        private static string MakeMessage(string userName, ObjectName objectName, Privileges privileges)
        {
            if (privileges == Privileges.None)
                return String.Format("User '{0}' has not enough privileges to operate on the object '{1}'.", userName, objectName);

            return String.Format("User '{0}' has not the privilege '{1}' on the object '{2}'.", userName, privileges, objectName);
        }
        public static ITableInfoBuilder Named(this ITableInfoBuilder builder, ObjectName tableName)
        {
            if (tableName == null)
                throw new ArgumentNullException("tableName");

            return builder.InSchema(tableName.ParentName).Named(tableName.Name);
        }
Beispiel #26
0
 public SimpleSelectNode(IQueryPlanNode child, ObjectName columnName, SqlExpressionType op, SqlExpression expression)
     : base(child)
 {
     ColumnName = columnName;
     OperatorType = op;
     Expression = expression;
 }
 public MissingPrivilegesException(string userName, ObjectName objectName, Privileges privileges, string message)
     : base(SecurityErrorCodes.MissingPrivileges, message)
 {
     UserName = userName;
     ObjectName = objectName;
     Privileges = privileges;
 }
 public ObjectInstance CreateMBean(object token, string className, ObjectName name, object[] arguments)
 {
     using (TemporarySecurityContext tsc = new TemporarySecurityContext(Authorize(token)))
      {
     return _server.CreateMBean(className, name, arguments);
      }
 }
 public string QuoteObjectName(ObjectName unquotedName)
 {
     if (!string.IsNullOrWhiteSpace(unquotedName.Schema))
         return _schemaProvider.QuoteObjectName(unquotedName.Schema) + '.' + _schemaProvider.QuoteObjectName(unquotedName.Name);
     else
         return _schemaProvider.QuoteObjectName(unquotedName.Name);
 }
Beispiel #30
0
 public JoinNode(IQueryPlanNode left, IQueryPlanNode right, ObjectName leftColumnName, SqlExpressionType @operator, SqlExpression rightExpression)
     : base(left, right)
 {
     LeftColumnName = leftColumnName;
     Operator = @operator;
     RightExpression = rightExpression;
 }
Beispiel #31
0
 private static string FormatMessage(ObjectName tableName, string constraintName, ObjectName linkedTableName)
 {
     return(String.Format("Attempt to DROP the table '{0}' that is linked by the constraint '{1}' to table '{2}'.", tableName, constraintName, linkedTableName));
 }
Beispiel #32
0
        private Privileges QueryGroupPrivileges(string groupName, DbObjectType objectType, ObjectName objectName,
                                                bool withOption, bool withPublic)
        {
            var grantTable = QueryContext.GetTable(SystemSchema.GroupGrantsTable);

            return(QueryPrivileges(QueryContext, grantTable, groupName, objectType, objectName, withOption, withPublic));
        }
Beispiel #33
0
        private Privileges QueryUserPrivileges(string userName, DbObjectType objectType, ObjectName objectName,
                                               bool withOption, bool withPublic)
        {
            // The system grants table.
            var grantTable = QueryContext.GetTable(SystemSchema.UserGrantsTableName);

            return(QueryPrivileges(QueryContext, grantTable, userName, objectType, objectName, withOption, withPublic));
        }
Beispiel #34
0
        private bool TryGetPrivilegesFromCache(string userName, DbObjectType objectType, ObjectName objectName, bool withOption, bool withPublic,
                                               out Privileges privileges)
        {
            if (grantsCache == null)
            {
                privileges = Privileges.None;
                return(false);
            }

            var key = new GrantCacheKey(userName, objectType, objectName.FullName, withOption, withPublic);

            return(grantsCache.TryGetValue(key, out privileges));
        }
 public TableDroppedEvent(int tableId, ObjectName tableName)
     : base(DbObjectType.Table, tableName)
 {
     TableId = tableId;
 }
        public static void HandleGameObjectQueryResponse(Packet packet)
        {
            var gameObject = new GameObjectTemplate();
            var entry      = packet.ReadEntry("Entry");

            if (entry.Value) // entry is masked
            {
                return;
            }

            var unk1 = packet.ReadInt32("Unk1 UInt32");

            if (unk1 == 0)
            {
                packet.ReadByte("Unk1 Byte");
                return;
            }

            gameObject.Type      = packet.ReadEnum <GameObjectType>("Type", TypeCode.Int32);
            gameObject.DisplayId = packet.ReadUInt32("Display ID");

            var name = new string[4];

            for (var i = 0; i < 4; i++)
            {
                name[i] = packet.ReadCString("Name", i);
            }
            gameObject.Name = name[0];

            gameObject.IconName    = packet.ReadCString("Icon Name");
            gameObject.CastCaption = packet.ReadCString("Cast Caption");
            gameObject.UnkString   = packet.ReadCString("Unk String");

            gameObject.Data = new int[32];
            for (var i = 0; i < gameObject.Data.Length; i++)
            {
                gameObject.Data[i] = packet.ReadInt32("Data", i);
            }


            gameObject.Size = packet.ReadSingle("Size");

            gameObject.QuestItems = new uint[packet.ReadByte("QuestItems Length")];

            for (var i = 0; i < gameObject.QuestItems.Length; i++)
            {
                gameObject.QuestItems[i] = (uint)packet.ReadEntry <Int32>(StoreNameType.Item, "Quest Item", i);
            }

            packet.ReadEnum <ClientType>("Expansion", TypeCode.UInt32);

            packet.ReadByte("Unk1 Byte");

            Storage.GameObjectTemplates.Add((uint)entry.Key, gameObject, packet.TimeSpan);

            var objectName = new ObjectName
            {
                ObjectType = ObjectType.GameObject,
                Name       = gameObject.Name,
            };

            Storage.ObjectNames.Add((uint)entry.Key, objectName, packet.TimeSpan);
        }
Beispiel #37
0
        static void Main(string[] args)
        {
            var connectorServerFactory = new RemotingConnectorServerFactory(100, new NullSecurityProvider());
            var connectorFactory       = new RemotingConnectorFactory(new NotificationFetcherConfig(true, TimeSpan.FromSeconds(1)));

            IMBeanServer server = MBeanServerFactory.CreateMBeanServer();
            Sample       o      = new Sample();
            ObjectName   name   = new ObjectName("Sample:a=b");

            server.RegisterMBean(o, name);
            Uri serviceUrl = new Uri("tcp://localhost:1234/MBeanServer.tcp");

            using (INetMXConnectorServer connectorServer = connectorServerFactory.NewNetMXConnectorServer(serviceUrl, server))
            {
                connectorServer.Start();

                using (INetMXConnector connector = connectorFactory.Connect(serviceUrl, null))
                {
                    IMBeanServerConnection remoteServer = connector.MBeanServerConnection;

                    remoteServer.AddNotificationListener(name, CounterChanged, null, null);

                    Console.WriteLine("******");
                    MBeanInfo info = remoteServer.GetMBeanInfo(name);
                    Console.WriteLine("MBean description: {0}", info.Description);
                    Console.WriteLine("MBean class name: {0}", info.ClassName);
                    foreach (MBeanAttributeInfo attributeInfo in info.Attributes)
                    {
                        Console.WriteLine("Attribute {0} ({1}) [{2}{3}]: {4}", attributeInfo.Name, attributeInfo.Description,
                                          attributeInfo.Readable ? "r" : "", attributeInfo.Writable ? "w" : "", attributeInfo.Type);
                    }
                    foreach (MBeanOperationInfo operationInfo in info.Operations)
                    {
                        Console.WriteLine("Operation {0} ({1}) [{2}]", operationInfo.Name, operationInfo.Description,
                                          operationInfo.Impact);
                    }
                    Console.WriteLine("******");

                    object counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Counter value is {0}", counter);

                    remoteServer.SetAttribute(name, "Counter", 5);
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    counter = remoteServer.Invoke(name, "AddAmount", new object[] { 5 });
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    counter = remoteServer.Invoke(name, "ResetCounter", new object[] { });
                    counter = remoteServer.GetAttribute(name, "Counter");

                    Console.WriteLine("Now, counter value is {0}", counter);

                    Console.ReadKey();
                }
            }
        }
Beispiel #38
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            var entry   = packet.ReadEntry("Entry");
            var hasData = packet.ReadBit();

            if (!hasData)
            {
                return; // nothing to do
            }
            var creature = new UnitTemplate();

            var lenS3 = (int)packet.ReadBits(11);

            creature.RacialLeader = packet.ReadBit("Racial Leader");

            var stringLens = new int[4][];

            for (var i = 0; i < 4; i++)
            {
                stringLens[i]    = new int[2];
                stringLens[i][0] = (int)packet.ReadBits(11);
                stringLens[i][1] = (int)packet.ReadBits(11);
            }

            var lenS4      = (int)packet.ReadBits(6);
            var lenS5      = (int)packet.ReadBits(11);
            var qItemCount = packet.ReadBits(22);

            packet.ResetBitReader();

            var name = new string[8];

            for (var i = 0; i < 4; ++i)
            {
                if (stringLens[i][0] > 1)
                {
                    packet.ReadCString("Female Name", i);
                }
                if (stringLens[i][1] > 1)
                {
                    name[i] = packet.ReadCString("Name", i);
                }
            }
            creature.Name = name[0];

            creature.Modifier1 = packet.ReadSingle("Modifier 1");
            if (lenS3 > 1)
            {
                creature.SubName = packet.ReadCString("Sub Name");
            }

            creature.Rank = packet.ReadEnum <CreatureRank>("Rank", TypeCode.Int32);

            creature.QuestItems = new uint[qItemCount];
            for (var i = 0; i < qItemCount; ++i)
            {
                creature.QuestItems[i] = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Quest Item", i);
            }

            creature.Type        = packet.ReadEnum <CreatureType>("Type", TypeCode.Int32);
            creature.KillCredits = new uint[2];
            for (var i = 0; i < 2; ++i)
            {
                creature.KillCredits[i] = packet.ReadUInt32("Kill Credit", i);
            }
            creature.Family = packet.ReadEnum <CreatureFamily>("Family", TypeCode.Int32);
            if (lenS4 > 1)
            {
                creature.IconName = packet.ReadCString("Icon Name");
            }

            creature.DisplayIds    = new uint[4];
            creature.DisplayIds[1] = packet.ReadUInt32("Display ID 1");
            creature.DisplayIds[0] = packet.ReadUInt32("Display ID 0");
            creature.MovementId    = packet.ReadUInt32("Movement ID");
            creature.DisplayIds[3] = packet.ReadUInt32("Display ID 3");

            creature.TypeFlags  = packet.ReadEnum <CreatureTypeFlag>("Type Flags", TypeCode.UInt32);
            creature.TypeFlags2 = packet.ReadUInt32("Creature Type Flags 2"); // Missing enum

            if (lenS5 > 1)
            {
                packet.ReadCString("string5");
            }
            creature.DisplayIds[2] = packet.ReadUInt32("Display ID 2");
            creature.Modifier2     = packet.ReadSingle("Modifier 2");
            creature.Expansion     = packet.ReadEnum <ClientType>("Expansion", TypeCode.UInt32);

            packet.AddSniffData(StoreNameType.Unit, entry.Key, "QUERY_RESPONSE");

            Storage.UnitTemplates.Add((uint)entry.Key, creature, packet.TimeSpan);

            var objectName = new ObjectName
            {
                ObjectType = ObjectType.Unit,
                Name       = creature.Name,
            };

            Storage.ObjectNames.Add((uint)entry.Key, objectName, packet.TimeSpan);
        }
Beispiel #39
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters, SqlType returnType)
     : this(routineName, parameters, returnType, FunctionType.Static)
 {
 }
Beispiel #40
0
 internal DropTableViolationException(ObjectName tableName, string constraintName, ObjectName linkedTableName)
     : base(SystemErrorCodes.TableDropViolation, FormatMessage(tableName, constraintName, linkedTableName))
 {
     TableName       = tableName;
     ConstraintName  = constraintName;
     LinkedTableName = linkedTableName;
 }
Beispiel #41
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters)
     : this(routineName, parameters, FunctionType.Static)
 {
 }
Beispiel #42
0
        public string GetQuery()
        {
            string          sql         = string.Empty;
            string          indexName   = IndexName.ToQuota();
            string          schemaName  = SchemaName.ToQuota();
            string          objectName  = ObjectName.ToQuota();
            string          partition   = IsPartitioned ? PartitionNumber.ToString() : "ALL";
            DataCompression compression = DataCompression;

            if (IsColumnstore)
            {
                if (FixType == IndexOp.RebuildColumnstore)
                {
                    compression = DataCompression.Columnstore;
                }

                if (FixType == IndexOp.RebuildColumnstoreArchive)
                {
                    compression = DataCompression.ColumnstoreArchive;
                }

                switch (FixType)
                {
                case IndexOp.Rebuild:
                case IndexOp.RebuildColumnstore:
                case IndexOp.RebuildColumnstoreArchive:
                    sql = $"ALTER INDEX [{indexName}]\n    " +
                          $"ON [{schemaName}].[{objectName}] REBUILD PARTITION = {partition}\n    " +
                          $"WITH (DATA_COMPRESSION = {compression.ToDescription()}, MAXDOP = {Settings.Options.MaxDop});";
                    break;

                case IndexOp.Reorganize:
                    sql = $"ALTER INDEX [{indexName}]\n    " +
                          $"ON [{schemaName}].[{objectName}] REORGANIZE PARTITION = {partition};";
                    break;

                case IndexOp.ReorganizeCompressAllRowGroup:
                    sql = $"ALTER INDEX [{indexName}]\n    " +
                          $"ON [{schemaName}].[{objectName}] REORGANIZE PARTITION = {partition}\n    " +
                          "WITH (COMPRESS_ALL_ROW_GROUPS = ON);";
                    break;
                }
            }
            else
            {
                if (FixType == IndexOp.RebuildPage)
                {
                    compression = DataCompression.Page;
                }
                else if (FixType == IndexOp.RebuildRow)
                {
                    compression = DataCompression.Row;
                }
                else if (FixType == IndexOp.RebuildNone)
                {
                    compression = DataCompression.None;
                }

                switch (FixType)
                {
                case IndexOp.CreateIndex:
                    bool isCreateOnline = Settings.ServerInfo.MajorVersion > Server.Sql2008 &&
                                          Settings.ServerInfo.IsOnlineRebuildAvailable &&
                                          Settings.Options.Online;

                    sql = $"CREATE NONCLUSTERED INDEX [{indexName}]\n" +
                          $"ON [{schemaName}].[{objectName}] ({IndexColumns})\n" +
                          (string.IsNullOrEmpty(IncludedColumns) ? "" : $"INCLUDE({IncludedColumns})\n") +
                          $"WITH (SORT_IN_TEMPDB = {(Settings.Options.SortInTempDb ? Options.ON : Options.OFF)}, " +
                          $"ONLINE = {(isCreateOnline ? Options.ON : Options.OFF)}, " +
                          (Settings.Options.FillFactor.IsBetween(1, 100)
                            ? $"FILLFACTOR = {Settings.Options.FillFactor}, "
                            : ""
                          ) +
                          (Settings.Options.DataCompression == Options.DEFAULT
                            ? ""
                            : $"DATA_COMPRESSION = {Settings.Options.DataCompression}, "
                          ) +
                          (Settings.Options.NoRecompute == Options.DEFAULT
                            ? ""
                            : $"STATISTICS_NORECOMPUTE = {Settings.Options.NoRecompute}, "
                          ) +
                          $"MAXDOP = {Settings.Options.MaxDop});";
                    break;

                case IndexOp.Rebuild:
                case IndexOp.RebuildPage:
                case IndexOp.RebuildRow:
                case IndexOp.RebuildNone:
                case IndexOp.RebuildOnline:
                case IndexOp.RebuildFillFactorZero:
                    if (IndexType == IndexType.Heap)
                    {
                        sql = $"ALTER TABLE [{schemaName}].[{objectName}] REBUILD PARTITION = {partition}\n    " +
                              $"WITH (DATA_COMPRESSION = {compression.ToDescription()}, MAXDOP = {Settings.Options.MaxDop});";
                    }
                    else
                    {
                        string onlineRebuild = "OFF";
                        if (FixType == IndexOp.RebuildOnline)
                        {
                            if (Settings.Options.WaitAtLowPriority && Settings.ServerInfo.MajorVersion >= Server.Sql2014)
                            {
                                onlineRebuild = $"ON (" +
                                                $"WAIT_AT_LOW_PRIORITY(MAX_DURATION = {Settings.Options.MaxDuration} MINUTES, " +
                                                $"ABORT_AFTER_WAIT = {Settings.Options.AbortAfterWait}))";
                            }
                            else
                            {
                                onlineRebuild = Options.ON;
                            }
                        }

                        sql = $"ALTER INDEX [{indexName}]\n    " +
                              $"ON [{schemaName}].[{objectName}] REBUILD PARTITION = {partition}\n    " +
                              $"WITH (SORT_IN_TEMPDB = {(Settings.Options.SortInTempDb ? Options.ON : Options.OFF)}, " +
                              $"ONLINE = {onlineRebuild}, " +
                              (Settings.Options.NoRecompute == Options.DEFAULT
                            ? ""
                            : $"STATISTICS_NORECOMPUTE = {Settings.Options.NoRecompute}, "
                              ) +
                              (FixType == IndexOp.RebuildFillFactorZero
                            ? "FILLFACTOR = 100, "
                            : (Settings.Options.FillFactor.IsBetween(1, 100)
                                  ? $"FILLFACTOR = {Settings.Options.FillFactor}, "
                                  : ""
                               )
                              ) +
                              $"DATA_COMPRESSION = {compression.ToDescription()}, " +
                              $"MAXDOP = {Settings.Options.MaxDop});";
                    }
                    break;

                case IndexOp.Reorganize:
                    sql = $"ALTER INDEX [{indexName}]\n    " +
                          $"ON [{schemaName}].[{objectName}] REORGANIZE PARTITION = {partition}\n    " +
                          $"WITH (LOB_COMPACTION = {(Settings.Options.LobCompaction ? Options.ON : Options.OFF)});";
                    break;

                case IndexOp.Disable:
                    sql = $"ALTER INDEX [{indexName}] ON [{schemaName}].[{objectName}] DISABLE;";
                    break;

                case IndexOp.Drop:
                    sql = $"DROP INDEX [{indexName}] ON [{schemaName}].[{objectName}];";
                    break;

                case IndexOp.UpdateStatsSample:
                case IndexOp.UpdateStatsResample:
                case IndexOp.UpdateStatsFull:
                    sql = $"UPDATE STATISTICS [{schemaName}].[{objectName}] [{indexName}]\n    " + (
                        FixType == IndexOp.UpdateStatsSample
                    ? $"WITH SAMPLE {Settings.Options.SampleStatsPercent} PERCENT;"
                    : (FixType == IndexOp.UpdateStatsFull ? "WITH FULLSCAN;" : "WITH RESAMPLE;")
                        );
                    break;
                }
            }

            return(sql);
        }
Beispiel #43
0
 /// <summary>
 /// Constructs a <see cref="FunctionInfo"/> without arguments.
 /// </summary>
 /// <param name="routineName">The name of the function.</param>
 /// <param name="functionType">The type of function this</param>
 public FunctionInfo(ObjectName routineName, FunctionType functionType)
     : this(routineName, (SqlType)null, functionType)
 {
 }
Beispiel #44
0
 public FunctionInfo(ObjectName routineName, RoutineParameter[] parameters, FunctionType functionType)
     : this(routineName, parameters, null, functionType)
 {
 }
Beispiel #45
0
 public IEnumerable <ObjectName> QueryNames(ObjectName name, QueryExp query)
 {
     return(contractDelegate.QueryNames(name, query));
 }
Beispiel #46
0
 public FunctionInfo(ObjectName routineName, SqlType returnType)
     : this(routineName, returnType, FunctionType.Static)
 {
 }
Beispiel #47
0
 public bool IsInstanceOf(ObjectName name, string className)
 {
     return(contractDelegate.IsInstanceOf(name, className));
 }
Beispiel #48
0
 public void RemoveNotificationListener(ObjectName name, ObjectName listener)
 {
     contractDelegate.RemoveNotificationListener(name, listener);
 }
Beispiel #49
0
 public MBeanInfo GetMBeanInfo(ObjectName name)
 {
     return(contractDelegate.GetMBeanInfo(name));
 }
Beispiel #50
0
 public bool IsRegistered(ObjectName name)
 {
     return(contractDelegate.IsRegistered(name));
 }
Beispiel #51
0
 public object GetAttribute(ObjectName name, string attributeName)
 {
     return(contractDelegate.GetAttribute(name, attributeName));
 }
Beispiel #52
0
 public object Invoke(ObjectName name, string operationName, object[] arguments)
 {
     return(contractDelegate.Invoke(name, operationName, arguments));
 }
Beispiel #53
0
 public void UnregisterMBean(ObjectName name)
 {
     contractDelegate.UnregisterMBean(name);
 }
Beispiel #54
0
 public IList <AttributeValue> GetAttributes(ObjectName name, string[] attributeNames)
 {
     return(contractDelegate.GetAttributes(name, attributeNames));
 }
Beispiel #55
0
 public void SetAttribute(ObjectName name, string attributeName, object value)
 {
     contractDelegate.SetAttribute(name, attributeName, value);
 }
Beispiel #56
0
 public ObjectInstance CreateMBean(string className, ObjectName name, object[] arguments)
 {
     return(contractDelegate.CreateMBean(className, name, arguments));
 }
Beispiel #57
0
 public static SqlPreCommand TruncateTable(ObjectName tableName) => new SqlPreCommandSimple($"TRUNCATE TABLE {tableName}");
Beispiel #58
0
 public IList <AttributeValue> SetAttributes(ObjectName name, IEnumerable <AttributeValue> namesAndValues)
 {
     return(contractDelegate.SetAttributes(name, namesAndValues));
 }
Beispiel #59
0
 public static SqlPreCommand DropView(ObjectName viewName)
 {
     return(new SqlPreCommandSimple("DROP VIEW {0}".FormatWith(viewName)));
 }
Beispiel #60
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlagOptionModel"/> class.
 /// </summary>
 public FlagOptionModel(string name)
 {
     this.name = new ObjectName(name);
 }