pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alexander Pyhalov <a.pyhalov@postgrespro.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Amit Langote <amitlangote09@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: join pushdown and issue with foreign update
Date: Tue, 01 Jun 2021 21:47:58 +0300
Message-ID: <e55f17943f708a265bad9d0015165bb2@postgrespro.ru> (raw)
In-Reply-To: <2845636.1622571541@sss.pgh.pa.us>
References: <7817fb9ebd6661cdf9b67dec6e129a78@postgrespro.ru>
	<ae6d414df6165d50ec9db4265f999c14@postgrespro.ru>
	<CA+HiwqHnLESTUQUQ3-MBxOatPK4P4uu2Br3+6KRxFfbBO=HgFw@mail.gmail.com>
	<050b90460c024dd21af53dbaaf8fd510@postgrespro.ru>
	<2845636.1622571541@sss.pgh.pa.us>

Tom Lane писал 2021-06-01 21:19:
> Alexander Pyhalov <a.pyhalov@postgrespro.ru> writes:
>> What about the following patch?
> 
> ISTM that using a specific rowtype rather than RECORD would be
> quite disastrous from the standpoint of bloating the number of
> distinct resjunk columns we need for a partition tree with a
> lot of children.  Maybe we'll have to go that way, but it seems
> like an absolute last resort.

Why do you think they are distinct?
In suggested patch all of them will have type of the common ancestor 
(root of the partition tree).

> 
> I think a preferable fix involves making sure that the correct
> record-type typmod is propagated to record_in in this context.
> Alternatively, maybe we could insert the foreign table's rowtype
> during execution of the input operation, without touching the
> plan as such.
> 
> Could we start by creating a test case that doesn't involve
> uncommittable hacks to the source code?

Yes, it seems the following works fine to reproduce the issue.

-- 
Best regards,
Alexander Pyhalov,
Postgres Professional

Attachments:

example.diff (text/x-diff, 999B) download diff --git a/contrib/postgres_fdw/sql/postgres_fdw.sql b/contrib/postgres_fdw/sql/postgres_fdw.sql index 78379bdea5b..4dbb80c3ee8 100644 --- a/contrib/postgres_fdw/sql/postgres_fdw.sql +++ b/contrib/postgres_fdw/sql/postgres_fdw.sql @@ -3262,3 +3262,16 @@ DROP TABLE join_tbl; ALTER SERVER loopback OPTIONS (DROP async_capable); ALTER SERVER loopback2 OPTIONS (DROP async_capable); + +CREATE TABLE base_tbl (a int, b int); +CREATE FOREIGN TABLE remote_tbl (a int, b int) + SERVER loopback OPTIONS (table_name 'base_tbl'); + +insert into remote_tbl select generate_series(1,100), generate_series(1,100); + +ANALYZE base_tbl; +ANALYZE remote_tbl; + +EXPLAIN (VERBOSE, COSTS OFF, SUMMARY OFF, TIMING OFF) +UPDATE remote_tbl d SET a= CASE WHEN current_timestamp> '2012-02-02'::timestamp THEN 5 ELSE 6 END FROM remote_tbl AS t (a, b) WHERE d.a = (t.a); +UPDATE remote_tbl d SET a= CASE WHEN current_timestamp> '2012-02-02'::timestamp THEN 5 ELSE 6 END FROM remote_tbl AS t (a, b) WHERE d.a = (t.a);

view thread (13+ messages)  latest in thread

Message-ID: <e55f17943f708a265bad9d0015165bb2@postgrespro.ru>
Permalink:  ../e55f17943f708a265bad9d0015165bb2@postgrespro.ru/
Also on:    postgresql.org/message-id/e55f17943f708a265bad9d0015165bb2@postgrespro.ru

 ·  · 

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-hackers@postgresql.org
  Cc: a.pyhalov@postgrespro.ru, tgl@sss.pgh.pa.us, amitlangote09@gmail.com
  Subject: Re: join pushdown and issue with foreign update
  In-Reply-To: <e55f17943f708a265bad9d0015165bb2@postgrespro.ru>
  References: <7817fb9ebd6661cdf9b67dec6e129a78@postgrespro.ru> <ae6d414df6165d50ec9db4265f999c14@postgrespro.ru> <CA+HiwqHnLESTUQUQ3-MBxOatPK4P4uu2Br3+6KRxFfbBO=HgFw@mail.gmail.com> <050b90460c024dd21af53dbaaf8fd510@postgrespro.ru> <2845636.1622571541@sss.pgh.pa.us> <e55f17943f708a265bad9d0015165bb2@postgrespro.ru>

* 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