Hi again,
I agree it's a bug. What about this patch:
Function.optimize(), after default:
default:
dataType = info.dataType;
DataType type = DataType.getDataType(dataType);
precision = type.defaultPrecision;
displaySize = type.defaultDisplaySize;
scale = type.defaultScale;
Regards,
Thomas
On Wed, Feb 11, 2009 at 8:26 PM, Thomas Mueller
<[email protected]> wrote:
> Hi,
>
> But in that case LOG(1) would say that is returns an integer. That
> would be incorrect as well, right? My test case (only works in the H2
> Console):
>
> drop table test;
> CREATE TABLE TEST(X INT);
> INSERT INTO TEST VALUES(1);
> @META select log(X) FROM TEST;
>
> Regards,
> Thomas
>
>
> On Wed, Feb 11, 2009 at 3:59 PM, Pavel <[email protected]> wrote:
>>
>> Hi Thomas,
>>
>> Example to demonstrate the bug is below. The fix would be:
>>
>> Function.java line 1684 (inside public Expression optimize(Session
>> session) throws SQLException )
>> to add after case POWER:
>>
>> case ACOS:
>> case ASIN:
>> case ATAN:
>> case ATAN2:
>> case CEILING:
>> case COS:
>> case DEGREES:
>> case EXP:
>> case LOG:
>> case LOG10:
>> case MOD:
>> case RAND:
>> case SIN:
>> case SQRT:
>> case TAN:
>>
>>
>>
>> @Test
>> public void testNumber() throws Exception {
>>
>> Class.forName("org.h2.Driver");
>> Connection ca = DriverManager.getConnection("jdbc:h2:mem:",
>> "", "");
>>
>> Statement stat = ca.createStatement();
>>
>> stat.execute("CREATE TABLE TEST(X INT)");
>> stat.execute("INSERT INTO TEST VALUES(1)");
>>
>> ResultSetMetaData meta = stat.executeQuery("select log(X) FROM
>> TEST").getMetaData();
>>
>> // RETURNS zero here
>> assertEquals(0, meta.getPrecision(1));
>>
>> stat.execute("DROP TABLE TEST");
>> ca.close();
>>
>> }
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---