Hello H2 folks.
When upgrading from H2 1.4.200 to 2.0.202 (also to latest 2.1.210), I noticed that what SYSDATE returns has changed and it no longer includes time information.
Details
For context I use H2 to build query tests for an app that uses an Oracle database and run H2 with MODE=Oracle.
These are the results I get from selecting sysdate and current_date from H2 1.x and 2.x:
-- H2 1.x
sysdate= 2022-01-20 12:33:37.966253
current_date= 2022-01-20 00:00:00.0
-- H2 2.x
sysdate= 2022-01-20 00:00:00.0
current_date= 2022-01-20 00:00:00.0
This is an issue for us since Oracle SYSDATE includes time information to second precision (also seems to be true of SYSDATE() in mysql). I couldn't find a reason for this change in the release notes.
While I'm uncertain as to why this would be a desirable change, looking through docs it did seem like there was maybe a way for me to change the behavior by using my own alias override. Except that also does not appear to work.
-- where Sysdate.sysdate just returns a timestamp with second precision
SET BUILTIN_ALIAS_OVERRIDE TRUE;
CREATE ALIAS CURRENT_DATE FOR "com.nsperkins.h2test.util.h2.Sysdate.sysdate";
CREATE ALIAS SYSDATE FOR "com.nsperkins.h2test.util.h2.Sysdate.sysdate";
sysdate= 2022-01-20 00:00:00.0
current_date= 2022-01-20 12:37:49.0
Interestingly enough the alias override for current_date did work, but the alias for sysdate appears to be ignored.
Questions
- Was the
SYSDATE behavior change intentional?
- If the change was intentional, could
MODE=Oracle have the more oracle-y SYSDATE behavior? For what it's worth current_date and sysdate both return time with second precision in Oracle but they have different timezone behavior.
- Is it a bug that
CREATE ALIAS SYSDATE... does not appear to have any effect?
- Is there maybe some other workaround I could do? I combed through the docs but did not see anything obvious.
Thanks.
Hello H2 folks.
When upgrading from H2
1.4.200to2.0.202(also to latest2.1.210), I noticed that whatSYSDATEreturns has changed and it no longer includes time information.Details
For context I use H2 to build query tests for an app that uses an Oracle database and run H2 with MODE=Oracle.
These are the results I get from selecting
sysdateandcurrent_datefrom H2 1.x and 2.x:This is an issue for us since Oracle
SYSDATEincludes time information to second precision (also seems to be true ofSYSDATE()in mysql). I couldn't find a reason for this change in the release notes.While I'm uncertain as to why this would be a desirable change, looking through docs it did seem like there was maybe a way for me to change the behavior by using my own alias override. Except that also does not appear to work.
Interestingly enough the alias override for
current_datedid work, but the alias forsysdateappears to be ignored.Questions
SYSDATEbehavior change intentional?MODE=Oraclehave the more oracle-ySYSDATEbehavior? For what it's worthcurrent_dateandsysdateboth return time with second precision in Oracle but they have different timezone behavior.CREATE ALIAS SYSDATE...does not appear to have any effect?Thanks.