Skip to content
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

Ensure qsort comparison function is transitive #6610

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .unreleased/fix_6610
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #6610 Ensure qsort comparison function is transitive
9 changes: 8 additions & 1 deletion src/planner/expand_hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,14 @@
static int
chunk_cmp_chunk_reloid(const void *c1, const void *c2)
{
return (*(Chunk **) c1)->table_id - (*(Chunk **) c2)->table_id;
Oid lhs = (*(Chunk **) c1)->table_id;
Oid rhs = (*(Chunk **) c2)->table_id;

if (lhs < rhs)
return -1;
if (lhs > rhs)
return 1;
return 0;

Check warning on line 868 in src/planner/expand_hypertable.c

View check run for this annotation

Codecov / codecov/patch

src/planner/expand_hypertable.c#L868

Added line #L868 was not covered by tests
}

static Chunk **
Expand Down
10 changes: 7 additions & 3 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -2819,10 +2819,14 @@
static int
chunk_index_mappings_cmp(const void *p1, const void *p2)
{
const ChunkIndexMapping *mapping[] = { *((ChunkIndexMapping *const *) p1),
*((ChunkIndexMapping *const *) p2) };
const ChunkIndexMapping *lhs = *((ChunkIndexMapping *const *) p1);
const ChunkIndexMapping *rhs = *((ChunkIndexMapping *const *) p2);

return mapping[0]->chunkoid - mapping[1]->chunkoid;
if (lhs->chunkoid < rhs->chunkoid)
return -1;
if (lhs->chunkoid > rhs->chunkoid)
return 1;
return 0;

Check warning on line 2829 in src/process_utility.c

View check run for this annotation

Codecov / codecov/patch

src/process_utility.c#L2828-L2829

Added lines #L2828 - L2829 were not covered by tests
}

/*
Expand Down