Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
5f9a56a
Fix handling of R/W expanded datums that are passed to SQL functions.
tglsfdc Aug 10, 2022
e5c72eb
Fix catalog lookup with the wrong snapshot during logical decoding.
Aug 11, 2022
2659c7c
Back-Patch "Add wait_for_subscription_sync for TAP tests."
Aug 12, 2022
377d3fa
doc: clarify DROP EXTENSION dependent members text
bmomjian Aug 12, 2022
1c3449c
doc: improve wal_level docs for the 'minimal' level
bmomjian Aug 12, 2022
e68b35a
doc: clarify CREATE TABLE AS ... IF NOT EXISTS
bmomjian Aug 12, 2022
021defb
doc: document the CREATE INDEX "USING" clause
bmomjian Aug 12, 2022
fc165d0
doc: clarify configuration file for Windows builds
bmomjian Aug 12, 2022
8a8a43c
doc: warn about security issues around log files
bmomjian Aug 12, 2022
cf901ee
doc: add section about heap-only tuples (HOT)
bmomjian Aug 12, 2022
4db1c8c
doc: add missing role attributes to user management section
bmomjian Aug 12, 2022
8183d6b
pg_upgrade: Fix some minor code issues
petere Aug 12, 2022
fa1ee5e
Catch stack overflow when recursing in transformFromClauseItem().
tglsfdc Aug 13, 2022
b02db5c
Avoid misbehavior when hash_table_bytes < bucket_size.
tglsfdc Aug 13, 2022
9133edc
Fix outdated --help message for postgres -f
michaelpq Aug 15, 2022
7c07ddb
Add missing bad-PGconn guards in libpq entry points.
tglsfdc Aug 15, 2022
a71825a
doc: fix wrong tag used in create sequence manual.
tatsuo-ishii Aug 16, 2022
826e57b
Fix replica identity check for a partitioned table.
Aug 16, 2022
b8d4174
doc: Remove reference to tty libpq connstring param
danielgustafsson Aug 16, 2022
d48a4af
Fix assert in logicalmsg_desc
tvondra Aug 16, 2022
920e86b
Fix subtly-incorrect matching of parent and child partitioned indexes.
tglsfdc Aug 18, 2022
c1bdf8a
Add CHECK_FOR_INTERRUPTS while decoding changes.
Aug 23, 2022
0920293
Doc: prefer sysctl to /proc/sys in docs and comments.
tglsfdc Aug 23, 2022
9092ea8
Doc: document possible need to raise kernel's somaxconn limit.
tglsfdc Aug 23, 2022
5a38548
Defend against stack overrun in a few more places.
tglsfdc Aug 24, 2022
f9b6d77
Use correct connection for cancellation in frontend's parallel slots
michaelpq Aug 27, 2022
c3daf01
Doc: fix example of recursive query.
tglsfdc Aug 28, 2022
e3b6a02
Prevent WAL corruption after a standby promotion.
robertmhaas Aug 29, 2022
22180bb
On NetBSD, force dynamic symbol resolution at postmaster start.
tglsfdc Aug 30, 2022
d1f57db
In the Snowball dictionary, don't try to stem excessively-long words.
tglsfdc Aug 31, 2022
47109a9
Prevent long-term memory leakage in autovacuum launcher.
tglsfdc Aug 31, 2022
8d7ca60
doc: simplify WITH clause syntax in CREATE DATABASE
bmomjian Aug 31, 2022
d02ba67
doc: show direction is optional in FETCH/MOVE's FROM/IN syntax
bmomjian Aug 31, 2022
e5ecc39
doc: document the maximum char/varchar length value
bmomjian Aug 31, 2022
bd6ad9d
doc: mention that SET TIME ZONE often needs to be quoted
bmomjian Sep 1, 2022
8b5399e
doc: warn of SECURITY DEFINER schemas for non-sql_body functions
bmomjian Sep 1, 2022
a10a5a5
doc: split out the NATURAL/CROSS JOIN in SELECT syntax
bmomjian Sep 1, 2022
0effb24
doc: clarify that pgcrypto's gen_random_uuid calls core func.
bmomjian Sep 1, 2022
1bbf6a4
doc: use FILTER in aggregate example
bmomjian Sep 1, 2022
8d9b46f
doc: mention "bloom" as a possible index access method
bmomjian Sep 1, 2022
1b38111
doc: in create statistics docs, mention analyze for parent info
bmomjian Sep 1, 2022
f03ffaf
Fix some possibly latent bugs in slab.c
david-rowley Sep 1, 2022
c94c562
Doc: Update struct Trigger definition.
Sep 2, 2022
c7460b6
doc: clarify recursion internal behavior
bmomjian Sep 3, 2022
68d670d
doc: simplify docs about analyze and inheritance/partitions
bmomjian Sep 3, 2022
7fe7ec0
doc: Fix two queries related to jsonb functions
michaelpq Sep 3, 2022
bc985dc
Doc: clarify partitioned table limitations
david-rowley Sep 5, 2022
857b490
Choose FK name correctly during partition attachment
alvherre Sep 8, 2022
463d9e9
Reject bogus output from uuid_create(3).
tglsfdc Sep 9, 2022
a7e1544
Fix possible omission of variable storage markers in ECPG.
tglsfdc Sep 9, 2022
89eba88
Fix NaN comparison in circle_same test
danielgustafsson Sep 12, 2022
5cc1d31
doc: Fix link to FreeBSD documentation project
danielgustafsson Sep 12, 2022
3d95002
Fix RAT check violation from e5c72eb
reshke Mar 16, 2026
493f7c5
Don't reference out-of-bounds array elements in brin_minmax_multi.c
david-rowley Sep 12, 2022
2034027
Expand palloc/pg_malloc API for more type safety
petere Sep 14, 2022
65a5481
Fix incorrect value for "strategy" with deflateParams() in walmethods.c
michaelpq Sep 14, 2022
c04f3d9
postgres_fdw: Avoid 'variable not found in subplan target list' error.
Sep 14, 2022
ae5a900
Detect format-string mistakes in the libpq_pipeline test module.
tglsfdc Sep 15, 2022
15bd047
Improve plpgsql's ability to handle arguments declared as RECORD.
tglsfdc Sep 16, 2022
80bb337
Include c.h instead of postgres.h in src/port/*p{read,write}*.c
anarazel Sep 17, 2022
36e38a4
Make check_usermap() parameter names consistent.
petergeoghegan Sep 17, 2022
c6128eb
Future-proof the recursion inside ExecShutdownNode().
tglsfdc Sep 19, 2022
f512e22
Fix incorrect variable types for origin IDs in decode.c
michaelpq Sep 20, 2022
3387c22
doc: Fix parameter name for pg_create_logical_replication_slot()
michaelpq Sep 20, 2022
088c3a6
Suppress variable-set-but-not-used warnings from clang 15.
tglsfdc Sep 20, 2022
b563f02
Suppress more variable-set-but-not-used warnings from clang 15.
tglsfdc Sep 21, 2022
cdbfa1d
docs: Fix snapshot name in SET TRANSACTION docs.
MasaoFujii Sep 22, 2022
5be2501
Fix thinko in comment.
Sep 22, 2022
356361d
Fix race condition where heap_delete() fails to pin VM page.
jeff-davis Sep 22, 2022
bd97eaf
Stop using PQsendQuery in libpq_pipeline
alvherre Sep 23, 2022
1315662
Add missing source files to pg_waldump/nls.mk
alvherre Sep 25, 2022
608424a
Change some errdetail() to errdetail_internal()
alvherre Sep 28, 2022
0ac462c
revert "warn of SECURITY DEFINER schemas for non-sql_body funcs"
bmomjian Sep 28, 2022
75298ac
doc: clarify internal behavior of RECURSIVE CTE queries
bmomjian Sep 28, 2022
64ff75f
Update comment in ExecInsert() regarding batch insertion.
Sep 29, 2022
6005f1d
doc: Fix PQsslAttribute docs for compression
danielgustafsson Sep 30, 2022
51785ea
Avoid improbable PANIC during heap_update, redux.
tglsfdc Sep 30, 2022
b715be8
Fix self-referencing foreign keys with partitioned tables
alvherre Oct 7, 2022
c400954
Ensure all perl test modules are installed
alvherre Oct 11, 2022
8860332
Harden pmsignal.c against clobbered shared memory.
tglsfdc Oct 11, 2022
41ad423
Doc: improve recommended systemd unit file.
tglsfdc Oct 12, 2022
ed23788
Fix typo in CREATE PUBLICATION reference page
alvherre Oct 13, 2022
dbe07d1
libpq: Reset singlerow flag correctly in pipeline mode
alvherre Oct 14, 2022
1f3c51b
Use libc's snprintf, not sprintf, for special cases in snprintf.c.
tglsfdc Oct 16, 2022
b0c7423
Rename parser token REF to REF_P to avoid a symbol conflict.
tglsfdc Oct 16, 2022
03297da
Fix EXPLAIN of SEARCH BREADTH FIRST with a constant initial value.
tglsfdc Oct 16, 2022
1872dcf
Guard against table-AM-less relations in planner.
tglsfdc Oct 17, 2022
afec5c3
Reject non-ON-SELECT rules that are named "_RETURN".
tglsfdc Oct 17, 2022
c16c626
doc: warn pg_stat_reset() can cause vacuum/analyze problems
bmomjian Oct 17, 2022
8b2a2f5
doc: move the mention of aggregate JSON functions up in section
bmomjian Oct 17, 2022
6967768
Track LLVM 15 changes.
macdice Oct 19, 2022
1c9b752
Fix assertion failures while processing NEW_CID record in logical dec…
Oct 20, 2022
0fedcc9
Doc: fix outdated wording about parallel seq scans
david-rowley Oct 20, 2022
3a98613
Fix executing invalidation messages generated by subtransactions duri…
Oct 21, 2022
904f1cf
Add CHECK_FOR_INTERRUPTS while restoring changes during decoding.
Oct 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -7739,6 +7739,95 @@ if test x"$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" = x"yes";
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Xclang -no-opaque-pointers, for BITCODE_CFLAGS" >&5
$as_echo_n "checking whether ${CLANG} supports -Xclang -no-opaque-pointers, for BITCODE_CFLAGS... " >&6; }
if ${pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CFLAGS=$CFLAGS
pgac_save_CC=$CC
CC=${CLANG}
CFLAGS="${BITCODE_CFLAGS} -Xclang -no-opaque-pointers"
ac_save_c_werror_flag=$ac_c_werror_flag
ac_c_werror_flag=yes
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers=yes
else
pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_c_werror_flag=$ac_save_c_werror_flag
CFLAGS="$pgac_save_CFLAGS"
CC="$pgac_save_CC"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers" >&5
$as_echo "$pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers" >&6; }
if test x"$pgac_cv_prog_CLANG_cflags__Xclang__no_opaque_pointers" = x"yes"; then
BITCODE_CFLAGS="${BITCODE_CFLAGS} -Xclang -no-opaque-pointers"
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANGXX} supports -Xclang -no-opaque-pointers, for BITCODE_CXXFLAGS" >&5
$as_echo_n "checking whether ${CLANGXX} supports -Xclang -no-opaque-pointers, for BITCODE_CXXFLAGS... " >&6; }
if ${pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_CXXFLAGS=$CXXFLAGS
pgac_save_CXX=$CXX
CXX=${CLANGXX}
CXXFLAGS="${BITCODE_CXXFLAGS} -Xclang -no-opaque-pointers"
ac_save_cxx_werror_flag=$ac_cxx_werror_flag
ac_cxx_werror_flag=yes
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

int
main ()
{

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers=yes
else
pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

ac_cxx_werror_flag=$ac_save_cxx_werror_flag
CXXFLAGS="$pgac_save_CXXFLAGS"
CXX="$pgac_save_CXX"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers" >&5
$as_echo "$pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers" >&6; }
if test x"$pgac_cv_prog_CLANGXX_cxxflags__Xclang__no_opaque_pointers" = x"yes"; then
BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -Xclang -no-opaque-pointers"
fi


NOT_THE_CFLAGS=""
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS" >&5
$as_echo_n "checking whether ${CLANG} supports -Wunused-command-line-argument, for NOT_THE_CFLAGS... " >&6; }
Expand Down
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,9 @@ if test "$with_llvm" = yes ; then
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])

PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-Xclang -no-opaque-pointers])
PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-Xclang -no-opaque-pointers])

NOT_THE_CFLAGS=""
PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, NOT_THE_CFLAGS, [-Wunused-command-line-argument])
if test -n "$NOT_THE_CFLAGS"; then
Expand Down
3 changes: 1 addition & 2 deletions contrib/pax_storage/src/test/regress/expected/geometry.out
Original file line number Diff line number Diff line change
Expand Up @@ -4344,9 +4344,8 @@ SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 ~= c2.f1;
<(100,200),10> | <(100,200),10>
<(100,1),115> | <(100,1),115>
<(3,5),0> | <(3,5),0>
<(3,5),NaN> | <(3,5),0>
<(3,5),NaN> | <(3,5),NaN>
(9 rows)
(8 rows)

-- Overlap with circle
SELECT c1.f1, c2.f1 FROM CIRCLE_TBL c1, CIRCLE_TBL c2 WHERE c1.f1 && c2.f1;
Expand Down
79 changes: 79 additions & 0 deletions contrib/postgres_fdw/expected/postgres_fdw.out
Original file line number Diff line number Diff line change
Expand Up @@ -2467,6 +2467,85 @@ SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = f

RESET enable_nestloop;
RESET enable_hashjoin;
-- test that add_paths_with_pathkeys_for_rel() arranges for the epq_path to
-- return columns needed by the parent ForeignScan node
EXPLAIN (VERBOSE, COSTS OFF)
SELECT * FROM local_tbl LEFT JOIN (SELECT ft1.*, COALESCE(ft1.c3 || ft2.c3, 'foobar') FROM ft1 INNER JOIN ft2 ON (ft1.c1 = ft2.c1 AND ft1.c1 < 100)) ss ON (local_tbl.c1 = ss.c1) ORDER BY local_tbl.c1 FOR UPDATE OF local_tbl;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LockRows
Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, (COALESCE((ft1.c3 || ft2.c3), 'foobar'::text)), local_tbl.ctid, ft1.*, ft2.*
-> Merge Left Join
Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, (COALESCE((ft1.c3 || ft2.c3), 'foobar'::text)), local_tbl.ctid, ft1.*, ft2.*
Merge Cond: (local_tbl.c1 = ft1.c1)
-> Index Scan using local_tbl_pkey on public.local_tbl
Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, local_tbl.ctid
-> Materialize
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, (COALESCE((ft1.c3 || ft2.c3), 'foobar'::text))
-> Foreign Scan
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, COALESCE((ft1.c3 || ft2.c3), 'foobar'::text)
Relations: (public.ft1) INNER JOIN (public.ft2)
Remote SQL: SELECT r4."C 1", r4.c2, r4.c3, r4.c4, r4.c5, r4.c6, r4.c7, r4.c8, CASE WHEN (r4.*)::text IS NOT NULL THEN ROW(r4."C 1", r4.c2, r4.c3, r4.c4, r4.c5, r4.c6, r4.c7, r4.c8) END, CASE WHEN (r5.*)::text IS NOT NULL THEN ROW(r5."C 1", r5.c2, r5.c3, r5.c4, r5.c5, r5.c6, r5.c7, r5.c8) END, r5.c3 FROM ("S 1"."T 1" r4 INNER JOIN "S 1"."T 1" r5 ON (((r4."C 1" = r5."C 1")) AND ((r4."C 1" < 100)))) ORDER BY r4."C 1" ASC NULLS LAST
-> Result
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, ft2.c3
-> Sort
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, (COALESCE((ft1.c3 || ft2.c3), 'foobar'::text)), ft2.c3
Sort Key: ft1.c1
-> Hash Join
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, COALESCE((ft1.c3 || ft2.c3), 'foobar'::text), ft2.c3
Hash Cond: (ft1.c1 = ft2.c1)
-> Foreign Scan on public.ft1
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (("C 1" < 100))
-> Hash
Output: ft2.*, ft2.c1, ft2.c3
-> Foreign Scan on public.ft2
Output: ft2.*, ft2.c1, ft2.c3
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1"
(29 rows)

ALTER SERVER loopback OPTIONS (DROP extensions);
ALTER SERVER loopback OPTIONS (ADD fdw_startup_cost '10000.0');
EXPLAIN (VERBOSE, COSTS OFF)
SELECT * FROM local_tbl LEFT JOIN (SELECT ft1.* FROM ft1 INNER JOIN ft2 ON (ft1.c1 = ft2.c1 AND ft1.c1 < 100 AND ft1.c1 = postgres_fdw_abs(ft2.c2))) ss ON (local_tbl.c3 = ss.c3) ORDER BY local_tbl.c1 FOR UPDATE OF local_tbl;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
LockRows
Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, local_tbl.ctid, ft1.*, ft2.*
-> Nested Loop Left Join
Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, local_tbl.ctid, ft1.*, ft2.*
Join Filter: (local_tbl.c3 = ft1.c3)
-> Index Scan using local_tbl_pkey on public.local_tbl
Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, local_tbl.ctid
-> Materialize
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*
-> Foreign Scan
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*
Filter: (ft1.c1 = postgres_fdw_abs(ft2.c2))
Relations: (public.ft1) INNER JOIN (public.ft2)
Remote SQL: SELECT r4."C 1", r4.c2, r4.c3, r4.c4, r4.c5, r4.c6, r4.c7, r4.c8, CASE WHEN (r4.*)::text IS NOT NULL THEN ROW(r4."C 1", r4.c2, r4.c3, r4.c4, r4.c5, r4.c6, r4.c7, r4.c8) END, CASE WHEN (r5.*)::text IS NOT NULL THEN ROW(r5."C 1", r5.c2, r5.c3, r5.c4, r5.c5, r5.c6, r5.c7, r5.c8) END, r5.c2 FROM ("S 1"."T 1" r4 INNER JOIN "S 1"."T 1" r5 ON (((r4."C 1" = r5."C 1")) AND ((r4."C 1" < 100)))) ORDER BY r4.c3 ASC NULLS LAST
-> Sort
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, ft2.c2
Sort Key: ft1.c3
-> Merge Join
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*, ft2.*, ft2.c2
Merge Cond: ((ft1.c1 = (postgres_fdw_abs(ft2.c2))) AND (ft1.c1 = ft2.c1))
-> Sort
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*
Sort Key: ft1.c1
-> Foreign Scan on public.ft1
Output: ft1.c1, ft1.c2, ft1.c3, ft1.c4, ft1.c5, ft1.c6, ft1.c7, ft1.c8, ft1.*
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (("C 1" < 100))
-> Sort
Output: ft2.*, ft2.c1, ft2.c2, (postgres_fdw_abs(ft2.c2))
Sort Key: (postgres_fdw_abs(ft2.c2)), ft2.c1
-> Foreign Scan on public.ft2
Output: ft2.*, ft2.c1, ft2.c2, postgres_fdw_abs(ft2.c2)
Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" ORDER BY "C 1" ASC NULLS LAST
(32 rows)

ALTER SERVER loopback OPTIONS (DROP fdw_startup_cost);
ALTER SERVER loopback OPTIONS (ADD extensions 'postgres_fdw');
DROP TABLE local_tbl;
-- check join pushdown in situations where multiple userids are involved
CREATE ROLE regress_view_owner SUPERUSER;
Expand Down
49 changes: 49 additions & 0 deletions contrib/postgres_fdw/postgres_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -5813,6 +5813,55 @@ add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel,

useful_pathkeys_list = get_useful_pathkeys_for_relation(root, rel);

/*
* Before creating sorted paths, arrange for the passed-in EPQ path, if
* any, to return columns needed by the parent ForeignScan node so that
* they will propagate up through Sort nodes injected below, if necessary.
*/
if (epq_path != NULL && useful_pathkeys_list != NIL)
{
PgFdwRelationInfo *fpinfo = (PgFdwRelationInfo *) rel->fdw_private;
PathTarget *target = copy_pathtarget(epq_path->pathtarget);

/* Include columns required for evaluating PHVs in the tlist. */
add_new_columns_to_pathtarget(target,
pull_var_clause((Node *) target->exprs,
PVC_RECURSE_PLACEHOLDERS));

/* Include columns required for evaluating the local conditions. */
foreach(lc, fpinfo->local_conds)
{
RestrictInfo *rinfo = lfirst_node(RestrictInfo, lc);

add_new_columns_to_pathtarget(target,
pull_var_clause((Node *) rinfo->clause,
PVC_RECURSE_PLACEHOLDERS));
}

/*
* If we have added any new columns, adjust the tlist of the EPQ path.
*
* Note: the plan created using this path will only be used to execute
* EPQ checks, where accuracy of the plan cost and width estimates
* would not be important, so we do not do set_pathtarget_cost_width()
* for the new pathtarget here. See also postgresGetForeignPlan().
*/
if (list_length(target->exprs) > list_length(epq_path->pathtarget->exprs))
{
/* The EPQ path is a join path, so it is projection-capable. */
Assert(is_projection_capable_path(epq_path));

/*
* Use create_projection_path() here, so as to avoid modifying it
* in place.
*/
epq_path = (Path *) create_projection_path(root,
rel,
epq_path,
target);
}
}

/* Create one path for each set of pathkeys we found above. */
foreach(lc, useful_pathkeys_list)
{
Expand Down
13 changes: 13 additions & 0 deletions contrib/postgres_fdw/sql/postgres_fdw.sql
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,19 @@ SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = f
AND ft1.c2 = ft5.c1 AND ft1.c2 = local_tbl.c1 AND ft1.c1 < 100 AND ft2.c1 < 100 FOR UPDATE;
RESET enable_nestloop;
RESET enable_hashjoin;

-- test that add_paths_with_pathkeys_for_rel() arranges for the epq_path to
-- return columns needed by the parent ForeignScan node
EXPLAIN (VERBOSE, COSTS OFF)
SELECT * FROM local_tbl LEFT JOIN (SELECT ft1.*, COALESCE(ft1.c3 || ft2.c3, 'foobar') FROM ft1 INNER JOIN ft2 ON (ft1.c1 = ft2.c1 AND ft1.c1 < 100)) ss ON (local_tbl.c1 = ss.c1) ORDER BY local_tbl.c1 FOR UPDATE OF local_tbl;

ALTER SERVER loopback OPTIONS (DROP extensions);
ALTER SERVER loopback OPTIONS (ADD fdw_startup_cost '10000.0');
EXPLAIN (VERBOSE, COSTS OFF)
SELECT * FROM local_tbl LEFT JOIN (SELECT ft1.* FROM ft1 INNER JOIN ft2 ON (ft1.c1 = ft2.c1 AND ft1.c1 < 100 AND ft1.c1 = postgres_fdw_abs(ft2.c2))) ss ON (local_tbl.c3 = ss.c3) ORDER BY local_tbl.c1 FOR UPDATE OF local_tbl;
ALTER SERVER loopback OPTIONS (DROP fdw_startup_cost);
ALTER SERVER loopback OPTIONS (ADD extensions 'postgres_fdw');

DROP TABLE local_tbl;

-- check join pushdown in situations where multiple userids are involved
Expand Down
2 changes: 1 addition & 1 deletion contrib/test_decoding/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ REGRESS = ddl xact rewrite toast permissions decoding_in_xact \
spill slot truncate stream stats twophase twophase_stream
ISOLATION = mxact delayed_startup ondisk_startup concurrent_ddl_dml \
oldest_xmin snapshot_transfer subxact_without_top concurrent_stream \
twophase_snapshot
twophase_snapshot catalog_change_snapshot

REGRESS_OPTS = --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf
ISOLATION_OPTS = --temp-config $(top_srcdir)/contrib/test_decoding/logical.conf
Expand Down
Loading
Loading