Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf9b0871

Browse files
committed
Merge remote-tracking branch 'pg/master' into fast2pc
2 parents62d662f +ad95664 commitf9b0871

File tree

63 files changed

+3142
-1992
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+3142
-1992
lines changed

‎contrib/file_fdw/input/file_fdw.source‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ SET ROLE file_fdw_user;
173173
\t on
174174
EXPLAIN (VERBOSE, COSTS FALSE) SELECT * FROM agg_text WHERE a > 0;
175175
\t off
176+
-- file FDW allows foreign tables to be accessed without user mapping
177+
DROP USER MAPPING FOR file_fdw_user SERVER file_server;
178+
SELECT * FROM agg_text ORDER BY a;
176179

177180
-- privilege tests for object
178181
SET ROLE file_fdw_superuser;

‎contrib/file_fdw/output/file_fdw.source‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@ EXPLAIN (VERBOSE, COSTS FALSE) SELECT * FROM agg_text WHERE a > 0;
322322
Foreign File: @abs_srcdir@/data/agg.data
323323

324324
\t off
325+
-- file FDW allows foreign tables to be accessed without user mapping
326+
DROP USER MAPPING FOR file_fdw_user SERVER file_server;
327+
SELECT * FROM agg_text ORDER BY a;
328+
a | b
329+
-----+---------
330+
0 | 0.09561
331+
42 | 324.78
332+
56 | 7.8
333+
100 | 99.097
334+
(4 rows)
335+
325336
-- privilege tests for object
326337
SET ROLE file_fdw_superuser;
327338
ALTER FOREIGN TABLE agg_text OWNER TO file_fdw_user;
@@ -333,9 +344,8 @@ SET ROLE file_fdw_superuser;
333344
-- cleanup
334345
RESET ROLE;
335346
DROP EXTENSION file_fdw CASCADE;
336-
NOTICE: drop cascades to8 other objects
347+
NOTICE: drop cascades to7 other objects
337348
DETAIL: drop cascades to server file_server
338-
drop cascades to user mapping for file_fdw_user on server file_server
339349
drop cascades to user mapping for file_fdw_superuser on server file_server
340350
drop cascades to user mapping for no_priv_user on server file_server
341351
drop cascades to foreign table agg_text

‎contrib/postgres_fdw/expected/postgres_fdw.out‎

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,13 +1958,30 @@ EXECUTE join_stmt;
19581958

19591959
-- change the session user to view_owner and execute the statement. Because of
19601960
-- change in session user, the plan should get invalidated and created again.
1961-
--While creating the plan, it should throw errorsincethere is no user mapping
1962-
--available for view_owner.
1961+
--The join will not be pushed downsincethe joining relations do not have a
1962+
--valid user mapping.
19631963
SET SESSION ROLE view_owner;
19641964
EXPLAIN (COSTS OFF, VERBOSE) EXECUTE join_stmt;
1965-
ERROR: user mapping not found for "view_owner"
1966-
EXECUTE join_stmt;
1967-
ERROR: user mapping not found for "view_owner"
1965+
QUERY PLAN
1966+
------------------------------------------------------------------
1967+
Limit
1968+
Output: t1.c1, t2.c1
1969+
-> Sort
1970+
Output: t1.c1, t2.c1
1971+
Sort Key: t1.c1, t2.c1
1972+
-> Hash Left Join
1973+
Output: t1.c1, t2.c1
1974+
Hash Cond: (t1.c1 = t2.c1)
1975+
-> Foreign Scan on public.ft4 t1
1976+
Output: t1.c1, t1.c2, t1.c3
1977+
Remote SQL: SELECT c1 FROM "S 1"."T 3"
1978+
-> Hash
1979+
Output: t2.c1
1980+
-> Foreign Scan on public.ft5 t2
1981+
Output: t2.c1
1982+
Remote SQL: SELECT c1 FROM "S 1"."T 4"
1983+
(16 rows)
1984+
19681985
RESET ROLE;
19691986
DEALLOCATE join_stmt;
19701987
CREATE VIEW v_ft5 AS SELECT * FROM ft5;
@@ -2021,6 +2038,40 @@ EXECUTE join_stmt;
20212038
----+----
20222039
(0 rows)
20232040

2041+
-- If a sub-join can't be pushed down, upper level join shouldn't be either.
2042+
EXPLAIN (COSTS false, VERBOSE)
2043+
SELECT t1.c1, t2.c1 FROM (ft5 t1 JOIN v_ft5 t2 ON (t1.c1 = t2.c1)) left join (ft5 t3 JOIN v_ft5 t4 ON (t3.c1 = t4.c1)) ON (t1.c1 = t3.c1);
2044+
QUERY PLAN
2045+
------------------------------------------------------------------
2046+
Hash Join
2047+
Output: t1.c1, ft5.c1
2048+
Hash Cond: (t1.c1 = ft5.c1)
2049+
-> Hash Right Join
2050+
Output: t1.c1
2051+
Hash Cond: (t3.c1 = t1.c1)
2052+
-> Hash Join
2053+
Output: t3.c1
2054+
Hash Cond: (t3.c1 = ft5_1.c1)
2055+
-> Foreign Scan on public.ft5 t3
2056+
Output: t3.c1, t3.c2, t3.c3
2057+
Remote SQL: SELECT c1 FROM "S 1"."T 4"
2058+
-> Hash
2059+
Output: ft5_1.c1
2060+
-> Foreign Scan on public.ft5 ft5_1
2061+
Output: ft5_1.c1
2062+
Remote SQL: SELECT c1 FROM "S 1"."T 4"
2063+
-> Hash
2064+
Output: t1.c1
2065+
-> Foreign Scan on public.ft5 t1
2066+
Output: t1.c1
2067+
Remote SQL: SELECT c1 FROM "S 1"."T 4"
2068+
-> Hash
2069+
Output: ft5.c1
2070+
-> Foreign Scan on public.ft5
2071+
Output: ft5.c1
2072+
Remote SQL: SELECT c1 FROM "S 1"."T 4"
2073+
(27 rows)
2074+
20242075
-- recreate the dropped user mapping for further tests
20252076
CREATE USER MAPPING FOR CURRENT_USER SERVER loopback;
20262077
DROP USER MAPPING FOR PUBLIC SERVER loopback;

‎contrib/postgres_fdw/postgres_fdw.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,6 +3910,16 @@ foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype,
39103910
List*joinclauses;
39113911
List*otherclauses;
39123912

3913+
/*
3914+
* Core code may call GetForeignJoinPaths hook even when the join
3915+
* relation doesn't have a valid user mapping associated with it. See
3916+
* build_join_rel() for details. We can't push down such join, since
3917+
* there doesn't exist a user mapping which can be used to connect to the
3918+
* foreign server.
3919+
*/
3920+
if (!OidIsValid(joinrel->umid))
3921+
return false;
3922+
39133923
/*
39143924
* We support pushing down INNER, LEFT, RIGHT and FULL OUTER joins.
39153925
* Constructing queries representing SEMI and ANTI joins is hard, hence

‎contrib/postgres_fdw/sql/postgres_fdw.sql‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,11 +478,10 @@ EXPLAIN (COSTS OFF, VERBOSE) EXECUTE join_stmt;
478478
EXECUTE join_stmt;
479479
-- change the session user to view_owner and execute the statement. Because of
480480
-- change in session user, the plan should get invalidated and created again.
481-
--While creating the plan, it should throw errorsincethere is no user mapping
482-
--available for view_owner.
481+
--The join will not be pushed downsincethe joining relations do not have a
482+
--valid user mapping.
483483
SET SESSION ROLE view_owner;
484484
EXPLAIN (COSTS OFF, VERBOSE) EXECUTE join_stmt;
485-
EXECUTE join_stmt;
486485
RESET ROLE;
487486
DEALLOCATE join_stmt;
488487

@@ -506,6 +505,10 @@ CREATE USER MAPPING FOR view_owner SERVER loopback;
506505
EXPLAIN (COSTS false, VERBOSE) EXECUTE join_stmt;
507506
EXECUTE join_stmt;
508507

508+
-- If a sub-join can't be pushed down, upper level join shouldn't be either.
509+
EXPLAIN (COSTS false, VERBOSE)
510+
SELECTt1.c1,t2.c1FROM (ft5 t1JOIN v_ft5 t2ON (t1.c1=t2.c1))left join (ft5 t3JOIN v_ft5 t4ON (t3.c1=t4.c1))ON (t1.c1=t3.c1);
511+
509512
-- recreate the dropped user mapping for further tests
510513
CREATEUSERMAPPING FORCURRENT_USER SERVER loopback;
511514
DROPUSER MAPPING FOR PUBLIC SERVER loopback;

‎doc/src/sgml/indices.sgml‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ CREATE INDEX test2_mm_idx ON test2 (major, minor);
395395
</para>
396396

397397
<para>
398-
Currently, only the B-tree, GiST and GIN index types support multicolumn
398+
Currently, only the B-tree, GiST, GIN, and BRIN
399+
index types support multicolumn
399400
indexes. Up to 32 columns can be specified. (This limit can be
400401
altered when building <productname>PostgreSQL</productname>; see the
401402
file <filename>pg_config_manual.h</filename>.)
@@ -440,6 +441,15 @@ CREATE INDEX test2_mm_idx ON test2 (major, minor);
440441
the query conditions use.
441442
</para>
442443

444+
<para>
445+
A multicolumn BRIN index can be used with query conditions that
446+
involve any subset of the index's columns. Like GIN and unlike B-tree or
447+
GiST, index search effectiveness is the same regardless of which index
448+
column(s) the query conditions use. The only reason to have multiple BRIN
449+
indexes instead of one multicolumn BRIN index on a single table is to have
450+
a different <literal>pages_per_range</literal> storage parameter.
451+
</para>
452+
443453
<para>
444454
Of course, each column must be used with operators appropriate to the index
445455
type; clauses that involve other operators will not be considered.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp