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 static IntervalType GetIntervalType(IntervalType type, long precision, int fractionalPrecision) { if ((type.Precision >= precision) && (type.Scale >= fractionalPrecision)) { return(type); } return(GetIntervalType(type.TypeCode, precision, fractionalPrecision)); }
public IntervalSecondData(long seconds, int nanos, IntervalType type) { if (seconds >= type.GetIntervalValueLimit()) { throw Error.GetError(0xd6b); } this.Units = seconds; this.Nanos = nanos; }
public static SqlType GetCombinedIntervalType(IntervalType type1, IntervalType type2) { int startType = (type2.StartIntervalType > type1.StartIntervalType) ? type1.StartIntervalType : type2.StartIntervalType; int endType = (type2.EndIntervalType > type1.EndIntervalType) ? type2.EndIntervalType : type1.EndIntervalType; long precision = (type1.Precision > type2.Precision) ? type1.Precision : type2.Precision; int fractionPrecision = (type1.Scale > type2.Scale) ? type1.Scale : type2.Scale; return(GetIntervalType(GetCombinedIntervalType(startType, endType), startType, endType, precision, fractionPrecision, false)); }
public IntervalMonthData(long months, IntervalType type) { if (months >= type.GetIntervalValueLimit()) { throw Error.GetError(0xd4e); } if (type.TypeCode == 0x65) { months -= months % 12L; } this.Units = months; }
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 IntervalSecondData(long seconds, long nanos, IntervalType type, bool normalise) { if (nanos >= 0x3b9aca00L) { long num2 = nanos / 0x3b9aca00L; nanos = nanos % 0x3b9aca00L; seconds += num2; } else if (nanos <= -1000000000L) { long num3 = -nanos / 0x3b9aca00L; nanos = -(-nanos % 0x3b9aca00L); seconds -= num3; } int num = DTIType.NanoScaleFactors[type.Scale]; nanos /= (long)num; nanos *= num; if ((seconds > 0L) && (nanos < 0L)) { nanos += 0x3b9aca00L; seconds -= 1L; } else if ((seconds < 0L) && (nanos > 0L)) { nanos -= 0x3b9aca00L; seconds += 1L; } num = DTIType.YearToSecondFactors[type.EndPartIndex]; seconds /= (long)num; seconds *= num; if (seconds >= type.GetIntervalValueLimit()) { throw Error.GetError(0xd6b); } this.Units = seconds; this.Nanos = (int)nanos; }
public static IntervalSecondData NewIntervalSeconds(long seconds, IntervalType type) { return(new IntervalSecondData(seconds, 0, type)); }
public static IntervalSecondData NewIntervalMinute(long minutes, IntervalType type) { return(new IntervalSecondData(minutes * 60L, 0, type)); }
public static IntervalSecondData NewIntervalHour(long hours, IntervalType type) { return(new IntervalSecondData((hours * 60L) * 60L, 0, type)); }
public static IntervalSecondData NewIntervalDay(long days, IntervalType type) { return(new IntervalSecondData(((days * 0x18L) * 60L) * 60L, 0, type)); }
public static SqlType GetDataType(int type, int collation, long precision, int scale) { if (type <= 0x19) { if (type > 12) { if (type == 0x10) { return(SqlBoolean); } if (type == 0x19) { return(SqlBigint); } } else { switch (type) { case -11: return(SqlUniqueIdentifier); case -6: return(Tinyint); case 0: return(SqlAllTypes); case 1: case 12: goto Label_0191; case 2: case 3: if (precision == 0) { precision = 0x7fffffffL; } return(NumberType.GetNumberType(type, precision, scale)); case 4: return(SqlInteger); case 5: return(SqlSmallint); case 6: if (precision > 0x35L) { throw Error.GetError(0x15d8, precision); } goto Label_0175; case 7: case 8: goto Label_0175; } } goto Label_0199; } if (type <= 40) { if (type == 30) { goto Label_00B5; } if (type == 40) { goto Label_0191; } goto Label_0199; } if ((type - 60) > 1) { switch (type) { case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: return(DateTimeType.GetDateTimeType(type, scale)); case 100: goto Label_0191; case 0x65: case 0x66: case 0x67: case 0x68: case 0x69: case 0x6a: case 0x6b: case 0x6c: case 0x6d: case 110: case 0x6f: case 0x70: case 0x71: return(IntervalType.GetIntervalType(type, precision, scale)); case 0x457: return(Other); } goto Label_0199; } Label_00B5: return(BinaryType.GetBinaryType(type, precision)); Label_0175: return(SqlDouble); Label_0191: return(CharacterType.GetCharacterType(type, precision)); Label_0199: throw Error.RuntimeError(0xc9, "Type"); }
public bool CanAdd(IntervalType other) { return((other.StartPartIndex >= base.StartPartIndex) && (other.EndPartIndex <= base.EndPartIndex)); }
public static IntervalMonthData NewIntervalYear(long years, IntervalType type) { return(new IntervalMonthData(years * 12L, type)); }
public static IntervalMonthData NewIntervalMonth(long months, IntervalType type) { return(new IntervalMonthData(months, type)); }