v1-delta.patch

text/plain

Filename: v1-delta.patch
Type: text/plain
Part: 0
Message: Re: Problem with default partition pruning

Patch

Format: unified
Series: patch v1
File+
src/backend/partitioning/partprune.c 8 4
diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c
index 8317318156..e64fd1cea6 100644
--- a/src/backend/partitioning/partprune.c
+++ b/src/backend/partitioning/partprune.c
@@ -2759,15 +2759,19 @@ get_matching_range_bounds(PartitionPruneContext *context,
 				 * instead as the offset of the upper bound of the greatest
 				 * partition that may contain lookup value.  If the lookup
 				 * value had exactly matched the bound, but it isn't
-				 * inclusive, no need add the adjacent partition.  If 'off' is
-				 * -1 indicating that all bounds are greater, then we simply
-				 * end up adding the first bound's offset, that is, 0.
+				 * inclusive, no need add the adjacent partition.
 				 */
-				else if (off < 0 || !is_equal || inclusive)
+				else if (!is_equal || inclusive)
 					maxoff = off + 1;
 				else
 					maxoff = off;
 			}
+			else
+				/*
+				 * 'off' is -1 indicating that all bounds are greater, so just
+				 * set the first bound's offset as maxoff.
+				 */
+				maxoff = off + 1;
 			break;
 
 		default: