db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jack Klebanoff <klebanoff-de...@sbcglobal.net>
Subject Re: [PATCH] Timestamp Arithmetic
Date Wed, 18 May 2005 15:40:42 GMT
I have attached a new patch that addresses some of Dan's concerns. The 
new patch uses the CURRENT_DATE mechanism to ensure that the same date 
is used throughout the lifetime of a statement. It puts the timestamp 
arithmetic compilation in the TernaryOperatorNode class to avoid adding 
another class to Derby's footprint. Thank you, Satheesh Bandaram, for 
suggesting TernaryOperatorNode.

The patch passed the derbyall test suite.

svn status is:
M      java\engine\org\apache\derby\impl\sql\compile\NodeFactoryImpl.java
M      
java\engine\org\apache\derby\impl\sql\compile\TernaryOperatorNode.java
M      java\engine\org\apache\derby\impl\sql\compile\sqlgrammar.jj
?      java\engine\org\apache\derby\impl\services\monitor\AntiGC.class
M      java\engine\org\apache\derby\iapi\sql\compile\C_NodeTypes.java
M      java\engine\org\apache\derby\iapi\types\DateTimeDataValue.java
M      java\engine\org\apache\derby\iapi\types\SQLDate.java
M      java\engine\org\apache\derby\iapi\types\SQLTime.java
M      java\engine\org\apache\derby\iapi\types\SQLTimestamp.java
M      java\engine\org\apache\derby\iapi\reference\SQLState.java
M      java\engine\org\apache\derby\loc\messages_en.properties
A      
java\testing\org\apache\derbyTesting\functionTests\tests\lang\timestampArith.java
A      
java\testing\org\apache\derbyTesting\functionTests\master\timestampArith.out
M      
java\testing\org\apache\derbyTesting\functionTests\suites\derbylang.runall

Further replies are embedded below.

Jack

Daniel John Debrunner wrote:

>Jack Klebanoff wrote:
>
>
>  
>
>>My copy of the JDBC 3.0 spec does not say what TIMESTAMPADD and
>>TIMESTAMPDIFF are supposed to do when the input is a date or time.
>>However the ODBC spec on Microsoft's web site specifies the above
>>behavior. My understanding is that JDBC follows ODBC here.
>>    
>>
>
>Dumb question, but did you see TIMESTAMPADD in the ODBC spec?
>
>Here I only see TIMESTAMPDIFF
>
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odbc/htm/odbctime__date__and_interval_functions.asp
>
>
>  
>
I think that Microsoft made a mistake in formatting that page. The 
"TIMESTAMPADD" title cell is missing from the table, but the table does 
describe the TIMESTAMPADD function. It is tacked on to the end of the 
description of the "SECOND" function.

>>>Then the naming of the new methods in DateTimeDataValue seemed wrong,
>>>I'm a great believer in ensuring such items and method names correctly
>>>reflect their purpose. This makes the code more readable.
>>>So we have
>>>
>>>      
>>>
>
>  
>
>>>It seems a more correct reflection of their names would be intervalAdd
>>>and intervalDiff.
>>> 
>>>
>>>      
>>>
>>The methods implement the TIMESTAMPADD and TIMESTAMPDIFF functions, so
>>their names seem appropriate to me.
>>    
>>
>
>But they could be used to implement more in the future, and people
>looking at just that code may not understand the tie in to JDBC/ODBC
>functions. We don't control how api functions are named, but we can
>control how Derby functions are named to reflect their functionality.
>
>  
>
I think that the method names are good: the timestampAdd method 
implements the TIMESTAMPADD escape function, the timestampDiff method 
implements the TIMESTAMPDIFF escape function. The Javadoc comments all 
say that they implement the JDBC escape function. If the methods are 
modified in the future to do more then we can also rename them at that 
time.

>>I think that this is a reasonable argument, but I think that we should
>>follow the JDBC/ODBC standard, warts and all.
>>    
>>
>
>Yep, I keep forgetting that the JDBC spec is based upon the ODBC spec.
>
>Dan.
>
>
>  
>


Mime
View raw message