Exemplo n.º 1
0
 private void ResolveTypesForConcat(Session session, Expression parent)
 {
     if (base.DataType == null)
     {
         if (base.nodes[0].IsUnresolvedParam())
         {
             base.nodes[0].DataType = base.nodes[1].DataType;
         }
         else if (base.nodes[1].IsUnresolvedParam())
         {
             base.nodes[1].DataType = base.nodes[0].DataType;
         }
         if ((base.nodes[0].DataType == null) || (base.nodes[1].DataType == null))
         {
             throw Error.GetError(0x15bf);
         }
         if (base.nodes[0].DataType.IsBinaryType() ^ base.nodes[1].DataType.IsBinaryType())
         {
             throw Error.GetError(0x15bd);
         }
         if (base.nodes[0].DataType.IsArrayType())
         {
             Expression replacement = base.nodes[1];
             if (replacement.OpType == 0x69)
             {
                 if (parent == null)
                 {
                     throw Error.GetError(0x15bb);
                 }
                 base.nodes[1]        = replacement.GetLeftNode();
                 replacement.nodes[0] = this;
                 parent.ReplaceNode(this, replacement);
             }
         }
         if (base.nodes[0].DataType.IsArrayType() ^ base.nodes[1].DataType.IsArrayType())
         {
             throw Error.GetError(0x15bb);
         }
         if (base.nodes[0].DataType.IsCharacterType() && !base.nodes[1].DataType.IsCharacterType())
         {
             SqlType characterType = CharacterType.GetCharacterType(12, (long)base.nodes[1].DataType.DisplaySize());
             base.nodes[1] = ExpressionOp.GetCastExpression(session, base.nodes[1], characterType);
         }
         if (base.nodes[1].DataType.IsCharacterType() && !base.nodes[0].DataType.IsCharacterType())
         {
             SqlType characterType = CharacterType.GetCharacterType(12, (long)base.nodes[0].DataType.DisplaySize());
             base.nodes[0] = ExpressionOp.GetCastExpression(session, base.nodes[0], characterType);
         }
         base.DataType = base.nodes[0].DataType.GetCombinedType(base.nodes[1].DataType, 0x24);
         if ((base.nodes[0].OpType == 1) && (base.nodes[1].OpType == 1))
         {
             base.SetAsConstantValue(session);
         }
     }
 }
Exemplo n.º 2
0
        public ExpressionOp(Expression e) : base(e.DataType.IsDateTimeTypeWithZone() ? 0x5b : 0x5c)
        {
            switch (e.DataType.TypeCode)
            {
            case 0x5c:
                base.nodes             = new Expression[2];
                base.nodes[0]          = e;
                base.nodes[0].DataType = e.DataType;
                base.DataType          = DateTimeType.GetDateTimeType(0x5e, e.DataType.Scale);
                break;

            case 0x5d:
                base.nodes             = new Expression[2];
                base.nodes[0]          = e;
                base.nodes[0].DataType = e.DataType;
                base.DataType          = DateTimeType.GetDateTimeType(0x5f, e.DataType.Scale);
                break;

            case 0x5e:
            {
                base.nodes = new Expression[1];
                ExpressionOp op1 = new ExpressionOp(0x5c, e, null)
                {
                    DataType = e.DataType
                };
                base.nodes[0] = op1;
                base.DataType = DateTimeType.GetDateTimeType(0x5c, e.DataType.Scale);
                break;
            }

            case 0x5f:
            {
                base.nodes = new Expression[1];
                ExpressionOp op2 = new ExpressionOp(0x5c, e, null)
                {
                    DataType = e.DataType
                };
                base.nodes[0] = op2;
                base.DataType = DateTimeType.GetDateTimeType(0x5d, e.DataType.Scale);
                break;
            }

            default:
                throw Error.RuntimeError(0xc9, "ExpressionOp");
            }
            base.Alias = e.Alias;
        }