public override SqlType GetCombinedType(SqlType other, int operation) { switch (operation) { case 0x20: if (!other.IsDateTimeType()) { if (other.IsIntervalType()) { IntervalType aggregateType = (IntervalType)this.GetAggregateType(other); return(GetIntervalType(aggregateType, 9L, aggregateType.Scale)); } break; } return(other.GetCombinedType(this, operation)); case 0x22: if (!other.IsNumberType()) { break; } return(GetIntervalType(this, 9L, base.Scale)); case 0x23: if (!other.IsNumberType()) { break; } return(this); default: return(this.GetAggregateType(other)); } throw Error.GetError(0x15ba); }
public override int PrecedenceDegree(SqlType other) { if (other.IsIntervalType()) { return(((IntervalType)other).EndPartIndex - base.EndPartIndex); } return(-2147483648); }
public override SqlType GetCombinedType(SqlType other, int operation) { if ((operation - 0x20) > 1) { if ((operation - 0x29) <= 5) { int num2; if (base.TypeCode == other.TypeCode) { return(this); } if (other.TypeCode == 0) { return(this); } if (!other.IsDateTimeType()) { throw Error.GetError(0x15ba); } DateTimeType type = (DateTimeType)other; if ((type.StartIntervalType > base.EndIntervalType) || (base.StartIntervalType > type.EndIntervalType)) { throw Error.GetError(0x15ba); } int scale = (base.Scale > type.Scale) ? base.Scale : type.Scale; bool flag = this._withTimeZone || type._withTimeZone; if (((type.StartIntervalType > base.StartIntervalType) ? base.StartIntervalType : type.StartIntervalType) == 0x68) { num2 = flag ? 0x5e : 0x5c; } else { num2 = flag ? 0x5f : 0x5d; } return(GetDateTimeType(num2, scale)); } } else { if (other.IsIntervalType()) { if ((base.TypeCode != 0x5b) && (other.Scale > base.Scale)) { return(GetDateTimeType(base.TypeCode, other.Scale)); } return(this); } if ((base.TypeCode == 0x5b) && other.IsNumberType()) { return(SqlType.SqlDate); } } throw Error.GetError(0x15ba); }
public static bool IsValidDatetimeRange(SqlType a, SqlType b) { if (!a.IsDateTimeType()) { return(false); } if (b.IsDateTimeType()) { return(((a.TypeCode != 0x5c) || (b.TypeCode != 0x5b)) && ((a.TypeCode != 0x5b) || (b.TypeCode != 0x5c))); } return(b.IsIntervalType() && ((DateTimeType)a).CanAdd((IntervalType)b)); }
public override SqlType GetAggregateType(SqlType other) { SqlType type3; if (base.TypeCode == other.TypeCode) { if ((base.Precision >= other.Precision) && (base.Scale >= other.Scale)) { return(this); } if ((base.Precision <= other.Precision) && (base.Scale <= other.Scale)) { return(other); } } if (other == SqlType.SqlAllTypes) { return(this); } if (other.IsCharacterType()) { return(other.GetAggregateType(this)); } if (!other.IsIntervalType()) { throw Error.GetError(0x15ba); } IntervalType type2 = (IntervalType)other; int startType = (type2.StartIntervalType > base.StartIntervalType) ? base.StartIntervalType : type2.StartIntervalType; int endType = (type2.EndIntervalType > base.EndIntervalType) ? type2.EndIntervalType : base.EndIntervalType; int combinedIntervalType = GetCombinedIntervalType(startType, endType); long precision = (base.Precision > other.Precision) ? base.Precision : other.Precision; int fractionPrecision = (base.Scale > other.Scale) ? base.Scale : other.Scale; try { type3 = GetIntervalType(combinedIntervalType, startType, endType, precision, fractionPrecision, false); } catch (Exception) { throw Error.GetError(0x15ba); } return(type3); }
public override bool CanConvertFrom(SqlType othType) { return((((othType.TypeCode == 0) || othType.IsCharacterType()) || othType.IsNumberType()) || (othType.IsIntervalType() && (this.IsYearMonthIntervalType() == ((IntervalType)othType).IsYearMonthIntervalType()))); }