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

Commit 4b0252a

Browse files
committed
[PGPRO-5306] more correct checking of b-tree search strategies
1 parent 2e174ba commit 4b0252a

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

‎src/pg_pathman.c‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,8 +1159,14 @@ handle_array(ArrayType *array,
11591159
bool elem_byval;
11601160
char elem_align;
11611161

1162-
/* Check if we can work with this strategy */
1163-
if (strategy == 0)
1162+
/*
1163+
* Check if we can work with this strategy
1164+
* We can work only with BTLessStrategyNumber, BTLessEqualStrategyNumber,
1165+
* BTEqualStrategyNumber, BTGreaterEqualStrategyNumber and BTGreaterStrategyNumber.
1166+
* If new search strategies appear in the future, then access optimizations from
1167+
* this function will not work, and the default behavior (handle_array_return:) will work.
1168+
*/
1169+
if (strategy == InvalidStrategy || strategy > BTGreaterStrategyNumber)
11641170
goto handle_array_return;
11651171

11661172
/* Get element's properties */
@@ -1177,8 +1183,12 @@ handle_array(ArrayType *array,
11771183
List *ranges;
11781184
int i;
11791185

1180-
/* This is only for paranoia's sake */
1181-
Assert(BTMaxStrategyNumber == 5 && BTEqualStrategyNumber == 3);
1186+
/* This is only for paranoia's sake (checking correctness of following take_min calculation) */
1187+
Assert(BTEqualStrategyNumber == 3
1188+
&& BTLessStrategyNumber < BTEqualStrategyNumber
1189+
&& BTLessEqualStrategyNumber < BTEqualStrategyNumber
1190+
&& BTGreaterEqualStrategyNumber > BTEqualStrategyNumber
1191+
&& BTGreaterStrategyNumber > BTEqualStrategyNumber);
11821192

11831193
/* Optimizations for <, <=, >=, > */
11841194
if (strategy != BTEqualStrategyNumber)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /