Skip to content

Incorrect DATE/TIMESTAMP conversion due to ignored database timezone #321

@dima-bzz

Description

@dima-bzz

Environment

  • Oracle Database: 19.11
  • OpenLogReplicator: 1.9.0

Database NLS Settings

NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_CHARACTERSET = CL8MSWIN1251

Problem

There is an issue with processing DATE and TIMESTAMP fields.

The date part is correct, but the time is shifted by +3 hours.

Logs

timezone: +03:00
db-timezone: +03:00
log-timezone: +03:00
host-timezone: +03:00

All timezones are aligned, but the resulting timestamp is still incorrect.

Analysis

The issue appears in Data::valuesToEpoch (src/builder/Builder.cpp).

Current implementation:

time_t timestamp = Data::valuesToEpoch(
    year, month, day, hour, minute, second, 0
);

Here, timezone offset is hardcoded as 0, which leads to incorrect conversion.

When using database timezone instead:

time_t timestamp = Data::valuesToEpoch(
    year, month, day, hour, minute, second, metadata->dbTimezone
);

the timestamp becomes correct.

Expected behavior

DATE and TIMESTAMP values should be converted using the database timezone (metadata->dbTimezone), not a hardcoded 0.

Suggestion

Replace timezone argument in valuesToEpoch with metadata->dbTimezone to ensure correct time conversion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions