pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Lukáš Sobotka <sobotka.luk@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Trouble with postgres_fdw & dblink extensions
Date: Thu, 15 Nov 2018 16:14:51 -0800
Message-ID: <9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com> (raw)
In-Reply-To: <CAJif3kL6tKJG+JS3N2oBiwOB7Nxa8a9yKvo6uLe30UYQuHKKDQ@mail.gmail.com>
References: <CAJif3kL6tKJG+JS3N2oBiwOB7Nxa8a9yKvo6uLe30UYQuHKKDQ@mail.gmail.com>

On 11/15/18 3:23 PM, Lukáš Sobotka wrote:
> Hi guys,
> 
> I would be grateful for some help. I am writing you because I am 
> confused about using data foreign wrappers and dblink. I attached 
> simplified script describing the problem.
> 
> What I am trying to do?
> I have two databases and I need to copy table from local database to the 
> remote one. For copying is used function which contains a few parts:
> 
>   *
> 
>     loading setting from foreign table (this part became a problematic)
> 
>   *
> 
>     creating destination table on remote db
> 
>   *
> 
>     importing foreign table
> 
>   *
> 
>     insert data into foreign table
> 
> If query using foreign table (with setting) is performed, command for 
> importing schema does not import new created table (it looks like table 
> is not created yet). So copying ends with error. The second calling of 
> function is all right (because destination table is already created from 
> first calling).
> If function does not use foreign table, the first calling of function 
> copies all data.
> 
> Why the new created remote table can not be imported to local database 
> when I had performed query on other foreign table? What am I missing?

Should this:

dblink('test_server_link' ...)

not be:

dblink_exec('test_server_link' ...)

> 
> I am using PG 9.6 (PostgreSQL 9.6.10 on x86_64-pc-linux-gnu, compiled by 
> gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit).
> 
> Best regards, Lukas
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (3+ messages)

Message-ID: <9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com>
Permalink:  ../9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com/
Also on:    postgresql.org/message-id/9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, sobotka.luk@gmail.com
  Subject: Re: Trouble with postgres_fdw & dblink extensions
  In-Reply-To: <9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com>
  References: <CAJif3kL6tKJG+JS3N2oBiwOB7Nxa8a9yKvo6uLe30UYQuHKKDQ@mail.gmail.com> <9ae87bc4-52b3-e771-732f-7e6040b45ce1@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox