Support setting fixed timezone for remote server #760
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows to avoid data loss in conversions between DATE and timestamp[tz]. It adds several options to set a fixed timezone of the Oracle server to preserve the implicit (server) timezone of DATE and TIMESTAMP Oracle types when converting them to timestamptz Postgres type and back.
Currently DATEs and TIMESTAMPs are presented as timestamp (local to any timezone) in Postgres, which assumes session's timezone. And even if foreign table's column type is set to timestamptz, the timezone is still assumed to be that of the session. To preserve a fixed/constant timezone a user is required to do explicit conversions from timestamp to timestamptz (and reversed) when working with DATE/TIEMSTAMP columns of foreign tables. This is error prone and unnecessary.
The ugly part right now is the pushdown of predicates. The conversions require analyzing multiple nodes/levels of predicate's expression, but the query is being generated in single step. It would be better to have an intermediate tree representation before stamping out the query for Oracle, where it would be possible to do complex analysis and transformations. The expression tree given by Postgres looks unfitting for this purpose.