Re: Option to dump foreign data in pg_dump

From: Luis Carril <luis(dot)carril(at)swarm64(dot)com>
To: Surafel Temesgen <surafel3000(at)gmail(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Subject: Re: Option to dump foreign data in pg_dump
Date: 2019-09-24 09:52:24
Message-ID: LEXPR01MB107278D18559745472696584E7840@LEXPR01MB1072.DEUPRD01.PROD.OUTLOOK.DE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Sep 20, 2019 at 6:20 PM Luis Carril <luis(dot)carril(at)swarm64(dot)com<mailto:luis(dot)carril(at)swarm64(dot)com>> wrote:
Hello,
thanks for the comments!

* + if (tdinfo->filtercond || tbinfo->relkind == RELKIND_FOREIGN_TABLE)

filter condition is not implemented completely yet so the logic only work on foreign table so I think its better to handle it separately

Note that there is another if condition that actually applies the the filtercondition if provided, also for a we need to do a COPY SELECT instead of a COPY TO

but we can't supplied where clause in pg_dump yet so filtercondtion is always NULL and the logic became true only on foreign table.

* I don’t understand the need for changing SELECT query .we can use the same SELECT query syntax for both regular table and foreign table

To which query do you refer? In the patch there are three queries: 1 retrieves foreign servers, another is the SELECT in the COPY that now it applies in case of a filter condition of a foreign table, and a third that retrieves the oid of a given foreign server.

SELECT on COPY

regards
Surafel
If we have a non-foreign table and filtercond is NULL, then we can do a `COPY table columns TO stdout`.
But if the table is foreign, the `COPY foreign-table columns TO stdout` is not supported by Postgres, so we have to do a `COPY (SELECT columns FROM foreign-table) TO sdout`

Now if in any case the filtercond is non-NULL, ie we have a WHERE clause, then for non-foreign and foreign tables we have to do a:
`COPY (SELECT columns FROM table) TO sdout`

So the COPY of a foreign table has to be done using the sub-SELECT just as a non-foreign table with filtercond, not like a non-foreign table without filtercond.

Cheers

Luis M Carril

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Victor Wagner 2019-09-24 10:07:31 Re: PostgreSQL12 and older versions of OpenSSL
Previous Message Michael Paquier 2019-09-24 09:49:17 Re: PostgreSQL12 and older versions of OpenSSL