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

Bugfix for timestamp persistence / transfer

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