aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/optimizer/path/allpaths.c12
-rw-r--r--src/backend/replication/logical/logical.c23
-rw-r--r--src/backend/utils/cache/syscache.c2
-rw-r--r--src/include/access/gin_tuple.h2
-rw-r--r--src/include/pg_config.h.in7
-rw-r--r--src/include/storage/waiteventset.h2
-rw-r--r--src/interfaces/ecpg/preproc/meson.build2
-rw-r--r--src/port/explicit_bzero.c4
-rw-r--r--src/port/pg_localeconv_r.c2
-rw-r--r--src/test/regress/expected/partition_join.out18
-rw-r--r--src/test/regress/sql/partition_join.sql3
-rw-r--r--src/tools/RELEASE_CHANGES3
12 files changed, 68 insertions, 12 deletions
diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index 905250b3325..6cc6966b060 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -1891,7 +1891,17 @@ generate_orderedappend_paths(PlannerInfo *root, RelOptInfo *rel,
*/
if (root->tuple_fraction > 0)
{
- double path_fraction = (1.0 / root->tuple_fraction);
+ double path_fraction = root->tuple_fraction;
+
+ /*
+ * Merge Append considers only live children relations. Dummy
+ * relations must be filtered out before.
+ */
+ Assert(childrel->rows > 0);
+
+ /* Convert absolute limit to a path fraction */
+ if (path_fraction >= 1.0)
+ path_fraction /= childrel->rows;
cheapest_fractional =
get_cheapest_fractional_path_for_pathkeys(childrel->pathlist,
diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c
index a8d2e024d34..1d56d0c4ef3 100644
--- a/src/backend/replication/logical/logical.c
+++ b/src/backend/replication/logical/logical.c
@@ -1828,7 +1828,19 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
SpinLockAcquire(&MyReplicationSlot->mutex);
- MyReplicationSlot->data.confirmed_flush = lsn;
+ /*
+ * Prevent moving the confirmed_flush backwards, as this could lead to
+ * data duplication issues caused by replicating already replicated
+ * changes.
+ *
+ * This can happen when a client acknowledges an LSN it doesn't have
+ * to do anything for, and thus didn't store persistently. After a
+ * restart, the client can send the prior LSN that it stored
+ * persistently as an acknowledgement, but we need to ignore such an
+ * LSN. See similar case handling in CreateDecodingContext.
+ */
+ if (lsn > MyReplicationSlot->data.confirmed_flush)
+ MyReplicationSlot->data.confirmed_flush = lsn;
/* if we're past the location required for bumping xmin, do so */
if (MyReplicationSlot->candidate_xmin_lsn != InvalidXLogRecPtr &&
@@ -1893,7 +1905,14 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn)
else
{
SpinLockAcquire(&MyReplicationSlot->mutex);
- MyReplicationSlot->data.confirmed_flush = lsn;
+
+ /*
+ * Prevent moving the confirmed_flush backwards. See comments above
+ * for the details.
+ */
+ if (lsn > MyReplicationSlot->data.confirmed_flush)
+ MyReplicationSlot->data.confirmed_flush = lsn;
+
SpinLockRelease(&MyReplicationSlot->mutex);
}
}
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 95a1d0a2749..f944453a1d8 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -396,7 +396,7 @@ SearchSysCacheCopy(int cacheId,
/*
* SearchSysCacheLockedCopy1
*
- * Meld SearchSysCacheLockedCopy1 with SearchSysCacheCopy(). After the
+ * Meld SearchSysCacheLocked1 with SearchSysCacheCopy(). After the
* caller's heap_update(), it should UnlockTuple(InplaceUpdateTupleLock) and
* heap_freetuple().
*/
diff --git a/src/include/access/gin_tuple.h b/src/include/access/gin_tuple.h
index 4a50565960f..702f7d12889 100644
--- a/src/include/access/gin_tuple.h
+++ b/src/include/access/gin_tuple.h
@@ -2,7 +2,7 @@
* gin.h
* Public header file for Generalized Inverted Index access method.
*
- * Copyright (c) 2006-2024, PostgreSQL Global Development Group
+ * Copyright (c) 2006-2025, PostgreSQL Global Development Group
*
* src/include/access/gin.h
*--------------------------------------------------------------------------
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index c3cc9fa856d..726a7c1be1f 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -91,6 +91,10 @@
`LLVMCreatePerfJITEventListener', and to 0 if you don't. */
#undef HAVE_DECL_LLVMCREATEPERFJITEVENTLISTENER
+/* Define to 1 if you have the declaration of `memset_s', and to 0 if you
+ don't. */
+#undef HAVE_DECL_MEMSET_S
+
/* Define to 1 if you have the declaration of `posix_fadvise', and to 0 if you
don't. */
#undef HAVE_DECL_POSIX_FADVISE
@@ -291,9 +295,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
-/* Define to 1 if you have the `memset_s' function. */
-#undef HAVE_MEMSET_S
-
/* Define to 1 if you have the `mkdtemp' function. */
#undef HAVE_MKDTEMP
diff --git a/src/include/storage/waiteventset.h b/src/include/storage/waiteventset.h
index aa65b7a35e7..dd514d52991 100644
--- a/src/include/storage/waiteventset.h
+++ b/src/include/storage/waiteventset.h
@@ -15,7 +15,7 @@
* functions.
*
*
- * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* src/include/storage/waiteventset.h
diff --git a/src/interfaces/ecpg/preproc/meson.build b/src/interfaces/ecpg/preproc/meson.build
index c9f4035053d..aa948efc0dc 100644
--- a/src/interfaces/ecpg/preproc/meson.build
+++ b/src/interfaces/ecpg/preproc/meson.build
@@ -98,4 +98,4 @@ tests += {
],
'deps': [ecpg_exe],
},
-} \ No newline at end of file
+}
diff --git a/src/port/explicit_bzero.c b/src/port/explicit_bzero.c
index 1d37b119bab..53766e86e94 100644
--- a/src/port/explicit_bzero.c
+++ b/src/port/explicit_bzero.c
@@ -12,9 +12,11 @@
*-------------------------------------------------------------------------
*/
+#define __STDC_WANT_LIB_EXT1__ 1 /* needed to access memset_s() */
+
#include "c.h"
-#if defined(HAVE_MEMSET_S)
+#if HAVE_DECL_MEMSET_S
void
explicit_bzero(void *buf, size_t len)
diff --git a/src/port/pg_localeconv_r.c b/src/port/pg_localeconv_r.c
index 4554ab84e9b..61510b2e0ea 100644
--- a/src/port/pg_localeconv_r.c
+++ b/src/port/pg_localeconv_r.c
@@ -3,7 +3,7 @@
* pg_localeconv_r.c
* Thread-safe implementations of localeconv()
*
- * Portions Copyright (c) 1996-2024, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
*
diff --git a/src/test/regress/expected/partition_join.out b/src/test/regress/expected/partition_join.out
index 6101c8c7cf1..d5368186caa 100644
--- a/src/test/regress/expected/partition_join.out
+++ b/src/test/regress/expected/partition_join.out
@@ -5260,6 +5260,24 @@ SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id DE
Index Cond: (id = x_2.id)
(11 rows)
+EXPLAIN (COSTS OFF) -- Should use NestLoop with parameterised inner scan
+SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id)
+ORDER BY x.id DESC LIMIT 2;
+ QUERY PLAN
+--------------------------------------------------------------------------------
+ Limit
+ -> Merge Append
+ Sort Key: x.id DESC
+ -> Nested Loop Left Join
+ -> Index Only Scan Backward using fract_t0_pkey on fract_t0 x_1
+ -> Index Only Scan using fract_t0_pkey on fract_t0 y_1
+ Index Cond: (id = x_1.id)
+ -> Nested Loop Left Join
+ -> Index Only Scan Backward using fract_t1_pkey on fract_t1 x_2
+ -> Index Only Scan using fract_t1_pkey on fract_t1 y_2
+ Index Cond: (id = x_2.id)
+(11 rows)
+
--
-- Test Append's fractional paths
--
diff --git a/src/test/regress/sql/partition_join.sql b/src/test/regress/sql/partition_join.sql
index b76c5451001..30f15ee9acb 100644
--- a/src/test/regress/sql/partition_join.sql
+++ b/src/test/regress/sql/partition_join.sql
@@ -1224,6 +1224,9 @@ SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id AS
EXPLAIN (COSTS OFF)
SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id) ORDER BY x.id DESC LIMIT 10;
+EXPLAIN (COSTS OFF) -- Should use NestLoop with parameterised inner scan
+SELECT x.id, y.id FROM fract_t x LEFT JOIN fract_t y USING (id)
+ORDER BY x.id DESC LIMIT 2;
--
-- Test Append's fractional paths
diff --git a/src/tools/RELEASE_CHANGES b/src/tools/RELEASE_CHANGES
index 94c5a0f3bfb..c0d75c213be 100644
--- a/src/tools/RELEASE_CHANGES
+++ b/src/tools/RELEASE_CHANGES
@@ -89,6 +89,9 @@ Starting a New Development Cycle
* Typically, we do pgindent and perltidy runs just before branching,
as well as before beta (complete steps from src/tools/pgindent/README)
+* It's also advisable to check that copyright years are up-to-date
+ (run src/tools/copyright.pl, commit any changes it finds)
+
* Create a branch in git for maintenance of the previous release
o on master branch, do:
git pull # be sure you have the latest "master"