Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

[PGPRO-5306] more correct checking of b-tree search strategies #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2021
Merged
Changes from all commits
Commits
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
18 changes: 14 additions & 4 deletions src/pg_pathman.c
Original file line number Diff line number Diff line change
Expand Up @@ -1159,8 +1159,14 @@ handle_array(ArrayType *array,
bool elem_byval;
char elem_align;

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

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

/* This is only for paranoia's sake */
Assert(BTMaxStrategyNumber == 5 && BTEqualStrategyNumber == 3);
/* This is only for paranoia's sake (checking correctness of following take_min calculation) */
Assert(BTEqualStrategyNumber == 3
&& BTLessStrategyNumber < BTEqualStrategyNumber
&& BTLessEqualStrategyNumber < BTEqualStrategyNumber
&& BTGreaterEqualStrategyNumber > BTEqualStrategyNumber
&& BTGreaterStrategyNumber > BTEqualStrategyNumber);

/* Optimizations for <, <=, >=, > */
if (strategy != BTEqualStrategyNumber)
Expand Down