Commit 57d11ef
committed
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.us1 parent d913928 commit 57d11ef
File tree
3 files changed
+47
-22
lines changed- contrib/postgres_fdw
3 files changed
+47
-22
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2368 | 2368 | | |
2369 | 2369 | | |
2370 | 2370 | | |
2371 | | - | |
| 2371 | + | |
| 2372 | + | |
2372 | 2373 | | |
2373 | 2374 | | |
2374 | 2375 | | |
2375 | 2376 | | |
2376 | 2377 | | |
2377 | 2378 | | |
2378 | | - | |
| 2379 | + | |
2379 | 2380 | | |
2380 | 2381 | | |
2381 | 2382 | | |
2382 | 2383 | | |
2383 | 2384 | | |
2384 | 2385 | | |
2385 | 2386 | | |
2386 | | - | |
| 2387 | + | |
2387 | 2388 | | |
2388 | 2389 | | |
2389 | 2390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4974 | 4974 | | |
4975 | 4975 | | |
4976 | 4976 | | |
4977 | | - | |
| 4977 | + | |
4978 | 4978 | | |
| 4979 | + | |
| 4980 | + | |
| 4981 | + | |
4979 | 4982 | | |
4980 | 4983 | | |
4981 | | - | |
| 4984 | + | |
4982 | 4985 | | |
4983 | 4986 | | |
4984 | 4987 | | |
4985 | 4988 | | |
4986 | 4989 | | |
4987 | 4990 | | |
4988 | 4991 | | |
| 4992 | + | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
4989 | 4996 | | |
4990 | 4997 | | |
4991 | 4998 | | |
| |||
4999 | 5006 | | |
5000 | 5007 | | |
5001 | 5008 | | |
5002 | | - | |
| 5009 | + | |
5003 | 5010 | | |
5004 | 5011 | | |
5005 | 5012 | | |
| |||
5008 | 5015 | | |
5009 | 5016 | | |
5010 | 5017 | | |
5011 | | - | |
| 5018 | + | |
5012 | 5019 | | |
5013 | 5020 | | |
| 5021 | + | |
5014 | 5022 | | |
5015 | 5023 | | |
5016 | 5024 | | |
| |||
5021 | 5029 | | |
5022 | 5030 | | |
5023 | 5031 | | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
5024 | 5037 | | |
5025 | 5038 | | |
5026 | 5039 | | |
| |||
5147 | 5160 | | |
5148 | 5161 | | |
5149 | 5162 | | |
5150 | | - | |
5151 | | - | |
5152 | | - | |
5153 | | - | |
5154 | | - | |
5155 | | - | |
5156 | | - | |
5157 | | - | |
5158 | | - | |
5159 | | - | |
5160 | | - | |
5161 | | - | |
5162 | | - | |
5163 | 5163 | | |
5164 | 5164 | | |
5165 | 5165 | | |
5166 | 5166 | | |
5167 | 5167 | | |
5168 | 5168 | | |
5169 | 5169 | | |
5170 | | - | |
| 5170 | + | |
| 5171 | + | |
| 5172 | + | |
| 5173 | + | |
| 5174 | + | |
| 5175 | + | |
| 5176 | + | |
| 5177 | + | |
| 5178 | + | |
| 5179 | + | |
| 5180 | + | |
| 5181 | + | |
5171 | 5182 | | |
5172 | 5183 | | |
5173 | 5184 | | |
| |||
5212 | 5223 | | |
5213 | 5224 | | |
5214 | 5225 | | |
| 5226 | + | |
| 5227 | + | |
| 5228 | + | |
| 5229 | + | |
| 5230 | + | |
| 5231 | + | |
| 5232 | + | |
| 5233 | + | |
| 5234 | + | |
| 5235 | + | |
| 5236 | + | |
| 5237 | + | |
| 5238 | + | |
5215 | 5239 | | |
5216 | 5240 | | |
5217 | 5241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
0 commit comments