-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL's TIMESTAMP support #281
Comments
Hi @nxhai98, Thanks for your concern. Can you please elaborate more on what is the issue with mapping MySQL's TIMESTAMP with PostgreSQL's timestamp? I have tested below simple test case -
I can see the same value in Postgres as well as MySQL side. If we change session timezone in MySQL then that value changes accordingly and this is what is mentioned in MySQL docs -
Also, do you think, we should set session time_zone to '+00:00' after establishing a connection with MySQL server to store date value in UTC timezone if timezone difference between MySQL and Postgres? |
Hi @surajkharage19,
I am concerned about the user not being able to know the value inserted by the mysql_fdw store in the MySQL server because user may not know time zone of mysql_fdw connection.
In you example, there is a confused data:
Yes, I think so. It's also important to consider PostgreSQL's time zone when selecting data. |
Thanks for your clarification. |
MySQL's TIMESTAMP has time zone information and thus it should be mapped to TIMESTAMPTZ on the PostgreSQL side. Reported on GitHub through issue #281 by Nguyen Xuan Hai (nxhai98). FDW-668, Suraj Kharage, reviewed by Jeevan Chalke.
PostgreSQL converts timestamp values to UTC before sending them to the remote server. Thus MySQL should treat it as UTC, and hence need this setting on MySQL. Reported on GitHub through issue #281 by Nguyen Xuan Hai (nxhai98). FDW-668, Suraj Kharage, reviewed by Jeevan Chalke.
Hi @nxhai98, We have committed the changes for the timestamp data type as reported by you. Please check on this. |
Hi team,
Currently, at
IMPORT FOREIGN SCHEMA
,mysql_fdw
map MySQL'sTIMESTAMP
with PostgreSQL'stimestamp
. I think it does not a correct behavior, based on: https://dev.mysql.com/doc/refman/8.0/en/datetime.html=> PostgreSQL's
timestamptz
should be the nearest mapped type.How do you think?
When map MySQL's
TIMESTAMP
with PostgreSQL'stimestamptz
, I found an issue:As you can see, timestamp value not same as value inserted by foreign table.
Root cause:
when insert, mysql_fdw adjust timestamptz value to UTC time zone:
mysql_fdw/mysql_query.c
Line 352 in 9204d9e
However, session time zone of mysql connection is not UTC/GMT and inserted value treated as in session time zone timestamp.
when select, mysql connection and postgres timezone may not the same and MySQL's TIMESTAMP literal have no time zone information => the PostgreSQL input function (cast) not work well.
The text was updated successfully, but these errors were encountered: