Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ezMh3-0005Lv-0m for pgsql-general@arkaria.postgresql.org; Fri, 23 Mar 2018 13:25:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ezMh1-0001hm-C9 for pgsql-general@arkaria.postgresql.org; Fri, 23 Mar 2018 13:25:15 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ezMh1-0001ga-01 for pgsql-general@lists.postgresql.org; Fri, 23 Mar 2018 13:25:15 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ezMgy-0003p4-07 for pgsql-general@lists.postgresql.org; Fri, 23 Mar 2018 13:25:13 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 9A70920E28; Fri, 23 Mar 2018 09:25:10 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute6.internal (MEProxy); Fri, 23 Mar 2018 09:25:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=Zt6+DPL35PuAzLpyRf/7yurOzKA1g tGt1hNrtDnMaj4=; b=HHnyB7QJTiWkDo5MaiRsQpNGwAQdwg5i3/BCbpku71ZLH Vgsa9xMdfMhh/Zz+G6pFluocNlw5tOVkZxGqSH1aYP4arco3rd6bltOquo+g6SB/ B6iNVdpBR8t8J6mOOXagh99DLqaqHX656RuME9XieNGRczsPH2wUq59xWwQDzqCX 97oDAGsnt8NJ/OhHag/SZg9Ij2IWMv9B/XTpRwoF6wMuSfN83phOC6NtqnuiREJo AHx6ILUhxqADXQaLU7B5mMjGPBYcE5Hdq5dap6DaIrM+38DfKHtaezXSo4hUMNjM rjhJLOM+cIfVl5m+54N2HADmYe6iOFVRrY9SwV/dw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=Zt6+DP L35PuAzLpyRf/7yurOzKA1gtGt1hNrtDnMaj4=; b=hf7/wZuvL7yqNQG+eBhWQb UJmWVQSXdZhga2K0+4iKT+SyXJOe4D2hR+bdtJ+z7BviYcFDSqklUs715OS4HBal bFBGErPIjMQH55aUq/6H6TJerpGLevRz5+fQfYM8mbN4N0CAi8JOGh5HWPx5TDXl Y1HTx0ncIri3lMAbDjQmVhENCh94bQW9biond7S1dQaHyCHfpOVMChC3I3/eCa3H 2aE4rOIRgpzynAhXSix79y/vImVKiCBGvwOBJaBjbdgc67GACB+xefMRBBtUydpa A+NVob4I4QNNbyafsmKX64zKknaWL82G+Ub+EaM1wG17uHGYI7fMwe8+ozQ201aQ == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id ED33C7E0EE; Fri, 23 Mar 2018 09:25:09 -0400 (EDT) Subject: Re: Use pgloader with FDW To: Patricia DECHANDOL , "pgsql-general@lists.postgresql.org" References: <9fdea26e-b84d-f171-d403-59cfd988fbda@aklaver.com> From: Adrian Klaver Message-ID: Date: Fri, 23 Mar 2018 06:25:09 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/23/2018 06:07 AM, Patricia DECHANDOL wrote: > Hello Adrian, > > So, if I well understand, the only solution is to wrap the mysql datetime columns to "text" columns in my foreign tables. > And then use a cast function to convert from text to date in Postgre when I want to use these columns ? There is also the option of changing the values in the MySQL database to either an actual datetime or NULL. Though there is the potential issue of what that would do to code that is pulling from the MySQL database. > > No other way. > The pgloader can't be used by the FDW to manage this point ? It has been a while since I used pgloader, but from what I remember it is a tool for doing the initial migration of data from MySQL/Sqlite/SQL Server to Postgres. What you seem to be looking for is pgloader to sit between the MySQL database and the Postgres one and do the transformation in real time. AFAIK that is not possible. > > > > -----Message d'origine----- > De : Adrian Klaver > Envoyé : vendredi 23 mars 2018 13:52 > À : Patricia DECHANDOL ; pgsql-general@lists.postgresql.org > Objet : Re: Use pgloader with FDW > > On 03/23/2018 03:55 AM, Patricia DECHANDOL wrote: >> Hello, >> >> I'm new to Postgresql and try to use the FDW with mysql database. >> >> Everything is OK to create my FDW and foreign tables, but I meet a >> problem when I try to do a select on a FOREIGN table containing >> datetime column which contains the value "0000-00-00 00:00:00" in mysql. > > That is MySQL's version of NULL for datetimes. It is not a valid datetime though. > >> >> Select on the foreign table fails. >> >> The mysql datetime column has been automatically wrapped to "timestamp >> without timezone" column in the foreign table by the instruction >> "import foreign schema" that I used. > >> >> How can I deal with this ? > > https://github.com/EnterpriseDB/mysql_fdw/issues/38 > >> >> I read about the pgloader with can manage this king of problem, but >> can't figure out how to use it with FDW. >> >> Thanks for your help. >> > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com