postgresql/contrib/postgres_fdw
Tomas Vondra 57d11ef028 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
2023-01-07 14:39:33 +01:00
..
expected Sample postgres_fdw tables remotely during ANALYZE 2022-12-30 23:16:01 +01:00
sql Sample postgres_fdw tables remotely during ANALYZE 2022-12-30 23:16:01 +01:00
.gitignore Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
Makefile postgres_fdw: Add function to list cached connections to foreign servers. 2021-01-18 15:11:08 +09:00
connection.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
deparse.c Check relkind before using TABLESAMPLE in postgres_fdw 2023-01-07 14:39:33 +01:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
option.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
postgres_fdw--1.0--1.1.sql postgres_fdw: Add functions to discard cached connections. 2021-01-26 15:35:54 +09:00
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.c Check relkind before using TABLESAMPLE in postgres_fdw 2023-01-07 14:39:33 +01:00
postgres_fdw.control postgres_fdw: Add function to list cached connections to foreign servers. 2021-01-18 15:11:08 +09:00
postgres_fdw.h Check relkind before using TABLESAMPLE in postgres_fdw 2023-01-07 14:39:33 +01:00
shippable.c Update copyright for 2023 2023-01-02 15:00:37 -05:00