EnterpriseDB / mysql_fdw

PostgreSQL foreign data wrapper for MySQL
Other
530 stars 162 forks source link

INIT_COMMAND does not override time zone setting #148

Open daskol opened 6 years ago

daskol commented 6 years ago

Option INIT_COMMAND does not override time zone setting for FDW. The reason is that mysqlBeginForeignScan procedure creates connection, runs INIT_COMMAND and then reset timezone. It seems that it is not necessary to force setting UTC time on connection. The propable solution is just remove this and this lines.

Several steps are enumerated bellow to reproduce reported behavior.

  1. Create view tz in MySQL and then create FDW in PostgreSQL like
    -- mysql
    CREATE VIEW tz AS SELECT NOW() AS now;
    -- postgresql
    CREATE TABLE tz (now timestamp) SERVER mysql_server OPTIONS (...);
  2. Also append option INIT_COMMAND to you MySQL server object
    ALTER SERVER mysql_master OPTIONS (init_command 'SET time_zone = "+03:00"');
  3. Suppose your MySQL server located in Europe/Moscow timezone. So, query databases in way like
    ur-database $> SELECT * FROM tz;
    -- MySQL output
    +---------------------+
    | now                 |
    +---------------------+
    | 2017-09-13 20:40:09 |
    +---------------------+
    --  PostgreSQL output
              now              
    -------------------------------
     2017-09-13 17:43:39
bbrodriges commented 6 years ago

Really annoying behaviour! Do you plan to do something?

ahsanhadi commented 6 years ago

We will look into this..

On Tue, 17 Oct 2017 at 9:18 PM, bbrodriges notifications@github.com wrote:

Really annoying behaviour! Do you plan to do something?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/EnterpriseDB/mysql_fdw/issues/148#issuecomment-337274136, or mute the thread https://github.com/notifications/unsubscribe-auth/AHmqpPngPaI8dttGazWcVSI9kko7LCsfks5stNM4gaJpZM4PWgnN .

-- Ahsan Hadi Snr Director Product Development EnterpriseDB Corporation The Enterprise Postgres Company

Phone: +92-51-8358874 Mobile: +92-333-5162114

Website: www.enterprisedb.com EnterpriseDB Blog: http://blogs.enterprisedb.com/ Follow us on Twitter: http://www.twitter.com/enterprisedb

This e-mail message (and any attachment) is intended for the use of the individual or entity to whom it is addressed. This message contains information from EnterpriseDB Corporation that may be privileged, confidential, or exempt from disclosure under applicable law. If you are not the intended recipient or authorized to receive this for the intended recipient, any use, dissemination, distribution, retention, archiving, or copying of this communication is strictly prohibited. If you have received this e-mail in error, please notify the sender immediately by reply e-mail and delete this message.