提交 b28e3a6b authored 作者: Thomas Mueller's avatar Thomas Mueller

Bugfix for timestamp persistence / transfer

上级 c53f1270
...@@ -526,7 +526,7 @@ public class Data { ...@@ -526,7 +526,7 @@ public class Data {
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
writeByte((byte) type); writeByte((byte) type);
writeVarLong(DateTimeUtils.getTimeLocalWithoutDst(ts)); writeVarLong(DateTimeUtils.getTimeLocalWithoutDst(ts));
writeVarInt(ts.getNanos()); writeVarInt(ts.getNanos() % 1000000);
} }
break; break;
} }
...@@ -1010,7 +1010,7 @@ public class Data { ...@@ -1010,7 +1010,7 @@ public class Data {
} }
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
return 1 + getVarLongLen(DateTimeUtils.getTimeLocalWithoutDst(ts)) + return 1 + getVarLongLen(DateTimeUtils.getTimeLocalWithoutDst(ts)) +
getVarIntLen(ts.getNanos()); getVarIntLen(ts.getNanos() % 1000000);
} }
case Value.GEOMETRY: case Value.GEOMETRY:
case Value.JAVA_OBJECT: { case Value.JAVA_OBJECT: {
......
...@@ -15,11 +15,9 @@ import java.io.Reader; ...@@ -15,11 +15,9 @@ import java.io.Reader;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.Socket; import java.net.Socket;
import java.sql.Date;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Time;
import java.sql.Timestamp; import java.sql.Timestamp;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
...@@ -383,11 +381,11 @@ public class Transfer { ...@@ -383,11 +381,11 @@ public class Transfer {
} else if (version >= Constants.TCP_PROTOCOL_VERSION_7) { } else if (version >= Constants.TCP_PROTOCOL_VERSION_7) {
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
writeLong(DateTimeUtils.getTimeLocalWithoutDst(ts)); writeLong(DateTimeUtils.getTimeLocalWithoutDst(ts));
writeInt(ts.getNanos()); writeInt(ts.getNanos() % 1000000);
} else { } else {
Timestamp ts = v.getTimestamp(); Timestamp ts = v.getTimestamp();
writeLong(ts.getTime()); writeLong(ts.getTime());
writeInt(ts.getNanos()); writeInt(ts.getNanos() % 1000000);
} }
break; break;
} }
...@@ -563,13 +561,15 @@ public class Transfer { ...@@ -563,13 +561,15 @@ public class Transfer {
return ValueTime.fromMillis(readLong()); return ValueTime.fromMillis(readLong());
case Value.TIMESTAMP: { case Value.TIMESTAMP: {
if (version >= Constants.TCP_PROTOCOL_VERSION_9) { if (version >= Constants.TCP_PROTOCOL_VERSION_9) {
return ValueTimestamp.fromDateValueAndNanos(readLong(), readLong()); return ValueTimestamp.fromDateValueAndNanos(
readLong(), readLong());
} else if (version >= Constants.TCP_PROTOCOL_VERSION_7) { } else if (version >= Constants.TCP_PROTOCOL_VERSION_7) {
return ValueTimestamp.fromMillisNanos( return ValueTimestamp.fromMillisNanos(
DateTimeUtils.getTimeUTCWithoutDst(readLong()), DateTimeUtils.getTimeUTCWithoutDst(readLong()),
readInt()); readInt() % 1000000);
} }
return ValueTimestamp.fromMillisNanos(readLong(), readInt()); return ValueTimestamp.fromMillisNanos(readLong(),
readInt() % 1000000);
} }
case Value.DECIMAL: case Value.DECIMAL:
return ValueDecimal.get(new BigDecimal(readString())); return ValueDecimal.get(new BigDecimal(readString()));
......
...@@ -225,7 +225,6 @@ public class TestDataPage extends TestBase implements DataHandler { ...@@ -225,7 +225,6 @@ public class TestDataPage extends TestBase implements DataHandler {
assertEquals(123, data.readInt()); assertEquals(123, data.readInt());
} }
private void testAll() { private void testAll() {
Data page = Data.create(this, 128); Data page = Data.create(this, 128);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论