pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Check relkind before using TABLESAMPLE in postgres_fdw
Date: Sat, 07 Jan 2023 13:44:02 +0000
Message-ID: <E1pE9UQ-002UQf-BJ@gemulon.postgresql.org> (raw)

Check relkind before using TABLESAMPLE in postgres_fdw

Check the remote relkind before trying to use TABLESAMPLE to acquire
sample from the remote relation. Even if the remote server version has
TABLESAMPLE support, the foreign table may point to incompatible relkind
(e.g. a view or a sequence).

If the relkind does not support TABLESAMPLE, error out if TABLESAMPLE
was requested specifically (as system/bernoulli), or fallback to random
just like we do for old server versions.

We currently end up disabling sampling for such relkind values anyway,
due to reltuples being -1 or 1, but that seems rather accidental, and
might get broken by improving reltuples estimates, etc.  So better to
make the check explicit.

Reported-by: Tom Lane
Discussion: https://postgr.es/m/951485.1672461744%40sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/57d11ef028d126f95595c08c62ffb4c5147d0f86

Modified Files
--------------
contrib/postgres_fdw/deparse.c      |  7 +++--
contrib/postgres_fdw/postgres_fdw.c | 60 ++++++++++++++++++++++++++-----------
contrib/postgres_fdw/postgres_fdw.h |  2 +-
3 files changed, 47 insertions(+), 22 deletions(-)



Message-ID: <E1pE9UQ-002UQf-BJ@gemulon.postgresql.org>
Permalink:  ../E1pE9UQ-002UQf-BJ@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1pE9UQ-002UQf-BJ@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Check relkind before using TABLESAMPLE in postgres_fdw
  In-Reply-To: <E1pE9UQ-002UQf-BJ@gemulon.postgresql.org>
  References: <E1pE9UQ-002UQf-BJ@gemulon.postgresql.org>

* 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