Jeremy Rickard
2017-01-28 22:28:47 UTC
Hi,
A SAP application suggests that a near-line storage database should be rolled forward to a point in time that includes microsecond precision.
DB2 syntax supports only second granularity, but I thought I'd test what happens if you specify microseconds. The answer is that it rounds, but more interestingly in the course of my test I get some seemingly incorrect results.
See below, using an example without the microseconds...
db2inst1: db2 connect to TEST
Database Connection Information
Database server = DB2/LINUXX8664 10.5.7
SQL authorization ID = DB2INST1
Local database alias = TEST
db2inst1: db2 "create table TIMES(TIMESTAMP timestamp not null default CURRENT_TIMESTAMP, TEXT varchar(30) not null)"
DB20000I The SQL command completed successfully.
db2inst1: db2 "insert into TIMES(text) values ('test 1')"
DB20000I The SQL command completed successfully.
db2inst1: db2 "insert into TIMES(text) values ('test 2')"
DB20000I The SQL command completed successfully.
db2inst1: db2 "insert into TIMES(text) values ('test 3')"
DB20000I The SQL command completed successfully.
db2inst1: db2 "select * from TIMES"
TIMESTAMP TEXT
-------------------------- ------------------------------
2017-01-27-10.16.34.563226 test 1
2017-01-27-10.17.21.205592 test 2
2017-01-27-10.17.21.250648 test 3
3 record(s) selected.
db2inst1: db2 connect reset
DB20000I The SQL command completed successfully.
db2inst1: db2 archive log for db TEST
DB20000I The ARCHIVE LOG command completed successfully.
db2inst1: db2 "restore database TEST from /home/db2inst1/backup/data without prompting"
SQL2540W Restore is successful, however a warning "2539" was encountered
during Database Restore while processing in No Interrupt mode.
db2inst1:~$ db2 "rollforward database TEST to 2017-01-27-10.17.20 using local time and complete"
Rollforward Status
Input database alias = TEST
Number of members have returned status = 1
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2017-01-27-10.17.20.000000 Local
DB20000I The ROLLFORWARD command completed successfully.
db2inst1:~$ db2 "select * from TIMES"
TIMESTAMP TEXT
-------------------------- ------------------------------
2017-01-27-10.16.34.563226 test 1
2017-01-27-10.17.21.205592 test 2
2 record(s) selected.
I would expect my rolled forward database to contain only row "test 1".
Anyone have any thoughts on this?
Regards,
Jeremy Rickard
A SAP application suggests that a near-line storage database should be rolled forward to a point in time that includes microsecond precision.
DB2 syntax supports only second granularity, but I thought I'd test what happens if you specify microseconds. The answer is that it rounds, but more interestingly in the course of my test I get some seemingly incorrect results.
See below, using an example without the microseconds...
db2inst1: db2 connect to TEST
Database Connection Information
Database server = DB2/LINUXX8664 10.5.7
SQL authorization ID = DB2INST1
Local database alias = TEST
db2inst1: db2 "create table TIMES(TIMESTAMP timestamp not null default CURRENT_TIMESTAMP, TEXT varchar(30) not null)"
DB20000I The SQL command completed successfully.
db2inst1: db2 "insert into TIMES(text) values ('test 1')"
DB20000I The SQL command completed successfully.
db2inst1: db2 "insert into TIMES(text) values ('test 2')"
DB20000I The SQL command completed successfully.
db2inst1: db2 "insert into TIMES(text) values ('test 3')"
DB20000I The SQL command completed successfully.
db2inst1: db2 "select * from TIMES"
TIMESTAMP TEXT
-------------------------- ------------------------------
2017-01-27-10.16.34.563226 test 1
2017-01-27-10.17.21.205592 test 2
2017-01-27-10.17.21.250648 test 3
3 record(s) selected.
db2inst1: db2 connect reset
DB20000I The SQL command completed successfully.
db2inst1: db2 archive log for db TEST
DB20000I The ARCHIVE LOG command completed successfully.
db2inst1: db2 "restore database TEST from /home/db2inst1/backup/data without prompting"
SQL2540W Restore is successful, however a warning "2539" was encountered
during Database Restore while processing in No Interrupt mode.
db2inst1:~$ db2 "rollforward database TEST to 2017-01-27-10.17.20 using local time and complete"
Rollforward Status
Input database alias = TEST
Number of members have returned status = 1
Member ID = 0
Rollforward status = not pending
Next log file to be read =
Log files processed = -
Last committed transaction = 2017-01-27-10.17.20.000000 Local
DB20000I The ROLLFORWARD command completed successfully.
db2inst1:~$ db2 "select * from TIMES"
TIMESTAMP TEXT
-------------------------- ------------------------------
2017-01-27-10.16.34.563226 test 1
2017-01-27-10.17.21.205592 test 2
2 record(s) selected.
I would expect my rolled forward database to contain only row "test 1".
Anyone have any thoughts on this?
Regards,
Jeremy Rickard