db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject svn commit: r1069849 - in /db/derby/code/branches/10.6: ./ java/engine/org/apache/derby/iapi/types/SQLChar.java java/engine/org/apache/derby/iapi/types/SQLTimestamp.java java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
Date Fri, 11 Feb 2011 15:51:15 GMT
Author: mikem
Date: Fri Feb 11 15:51:15 2011
New Revision: 1069849

URL: http://svn.apache.org/viewvc?rev=1069849&view=rev
Log:
DERBY-4625: TIMESTAMP function doesn't accept nanoseconds

backported change #999479 from trunk to 10.6 branch.

Patch contributed by C.S. Nirmal J. Fernando <nirmal070125@gmail.com>. 


Modified:
    db/derby/code/branches/10.6/   (props changed)
    db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLChar.java
    db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java
    db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java

Propchange: db/derby/code/branches/10.6/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 11 15:51:15 2011
@@ -1,2 +1,2 @@
-/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964115,964402,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033485,1033864,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250
+/db/derby/code/trunk:938547,938796,938959,939231,940462,940469,941627,942031,942286,942476,942480,942587,944152,946794,948045,948069,951346,951366,952138,952237,952581,954344,954421,954544,954748,955001,955540,955634,956075,956234,956445,956569,956659,957260,957902,958163,958257,958264,958508,958522,958555,958618,958939,959550,961892,962716,963206,963705,964115,964402,965647,967304,980684,986689,986834,987539,989099,990292,997325,998170,999119,999479,1002291,1002682,1002853,1021426,1025795,1028716,1030043,1033485,1033864,1038514,1040658,1053724,1055169,1062096,1063809,1065061,1067250
 /db/derby/docs/trunk:954344

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLChar.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLChar.java?rev=1069849&r1=1069848&r2=1069849&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLChar.java (original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLChar.java Fri Feb
11 15:51:15 2011
@@ -1566,19 +1566,17 @@ readingLoop:
                 formatJDBCTime( cal, sb);
                 sb.append('.');
 
-                int micros = 
-                    (theValue.getNanos() + SQLTimestamp.FRACTION_TO_NANO/2) / 
-                        SQLTimestamp.FRACTION_TO_NANO;
+                int nanos = theValue.getNanos();
 
-                if (micros == 0)
+                if (nanos == 0)
                 {
                     // Add a single zero after the decimal point to match
                     // the format from Timestamp.toString().
                     sb.append('0');
                 }
-                else if (micros > 0)
+                else if (nanos > 0)
                 {
-                    String microsStr = Integer.toString( micros);
+                    String microsStr = Integer.toString( nanos);
                     if(microsStr.length() > SQLTimestamp.MAX_FRACTION_DIGITS)
                     {
                         sb.append(

Modified: db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java?rev=1069849&r1=1069848&r2=1069849&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java
(original)
+++ db/derby/code/branches/10.6/java/engine/org/apache/derby/iapi/types/SQLTimestamp.java
Fri Feb 11 15:51:15 2011
@@ -85,8 +85,8 @@ public final class SQLTimestamp extends 
 						implements DateTimeDataValue
 {
 
-    static final int MAX_FRACTION_DIGITS = 6; // Only microsecond resolution on conversion
to/from strings
-    static final int FRACTION_TO_NANO = 1000; // 10**(9 - MAX_FRACTION_DIGITS)
+    static final int MAX_FRACTION_DIGITS = 9; // Only nanosecond resolution on conversion
to/from strings
+    static final int FRACTION_TO_NANO = 1; // 10**(9 - MAX_FRACTION_DIGITS)
 
     static final int ONE_BILLION = 1000000000;
     

Modified: db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java?rev=1069849&r1=1069848&r2=1069849&view=diff
==============================================================================
--- db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
(original)
+++ db/derby/code/branches/10.6/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DateTimeTest.java
Fri Feb 11 15:51:15 2011
@@ -1236,16 +1236,16 @@ public final class DateTimeTest extends 
     }
     
     /**
-     *  Don't allow more than microseconds in ISO format: cloudscape rejects.
+     * Don't allow more than nanoseconds in ISO format.
      */
-    public void testISOFormat_MoreThanMicroseconds() throws SQLException{
+    public void testISOFormat_MoreThanNanoseconds() throws SQLException{
         Statement st = createStatement();
         
         assertStatementError("22007", st, "insert into ts (ts1) values "
-                + "('2003-03-05-17.05.43.999999999')");
+                + "('2003-03-05-17.05.43.999999999999')");
 
         assertStatementError("22007", st, " insert into ts (ts1) values "
-                + "('2003-03-05-17.05.43.999999000')");
+                + "('2003-03-05-17.05.43.999999999000')");
 
         st.close();
     }
@@ -1785,6 +1785,15 @@ public final class DateTimeTest extends 
     }
 
     /**
+     * Test case to show that timestamp function accepts nanoseconds
+     * resolution (DERBY-4625).
+     */
+    public void testNanosecondResolution() throws SQLException{
+    	assertSingleValue("values timestamp('2010-04-21 12:00:00.123456789')",
+    			"2010-04-21 12:00:00.123456789");
+    }
+
+    /**
      * Execute an SQL statement and check that it returns a single, specific
      * value.
      *



Mime
View raw message