-
Roy Lyseng authored
In the user manual, the functions ROUND and TRUNCATE are said to produce the same result type as that of the first argument, however that is not always true. Especially, some types are different when the second argument (the decimal precision) is const vs. non-const. This patch adjusts the resolved type to be in better accordance with the type of the first argument. For all integer types, the resolved type is BIGINT. For all floating point types, the resolved type is DOUBLE. For all non-numeric types, the resolved type is DOUBLE. For the type DECIMAL, the resolved typs is also DECIMAL. The type attributes are also copied from the first argument, except for the type DECIMAL, when the second argument is a constant value: - When the desired number of decimal places is less than the scale of the argument, the scale of the result is adjusted accordingly. The precision of the result is also adjusted. In addition, for the function ROUND the precision is extended with one position to accomodate for rounding that increases the number of significant digits. Example: ROUND(99.999, 2). Here, the type of the argument is DECIMAL(5, 3). The type of the result is DECIMAL(5,2), since the result of this operation is 100.00. - With negative second argument, the type is adjusted to have scale 0 and a corresponding precision. Reviewed by: Guilhem Bichot <guilhem.bichot@oracle.com> Change-Id: Id5af0be433cdd52fc2e7a240de72cdc838d2722e
Roy Lyseng authoredIn the user manual, the functions ROUND and TRUNCATE are said to produce the same result type as that of the first argument, however that is not always true. Especially, some types are different when the second argument (the decimal precision) is const vs. non-const. This patch adjusts the resolved type to be in better accordance with the type of the first argument. For all integer types, the resolved type is BIGINT. For all floating point types, the resolved type is DOUBLE. For all non-numeric types, the resolved type is DOUBLE. For the type DECIMAL, the resolved typs is also DECIMAL. The type attributes are also copied from the first argument, except for the type DECIMAL, when the second argument is a constant value: - When the desired number of decimal places is less than the scale of the argument, the scale of the result is adjusted accordingly. The precision of the result is also adjusted. In addition, for the function ROUND the precision is extended with one position to accomodate for rounding that increases the number of significant digits. Example: ROUND(99.999, 2). Here, the type of the argument is DECIMAL(5, 3). The type of the result is DECIMAL(5,2), since the result of this operation is 100.00. - With negative second argument, the type is adjusted to have scale 0 and a corresponding precision. Reviewed by: Guilhem Bichot <guilhem.bichot@oracle.com> Change-Id: Id5af0be433cdd52fc2e7a240de72cdc838d2722e
Loading