Skip to content

Commit 91143c0

Browse files
committed
Add invariants check to get_useful_group_keys_orderings()
This commit introduces invariants checking of generated orderings in get_useful_group_keys_orderings() for assert-enabled builds. Discussion: https://postgr.es/m/a663f0f6-cbf6-49aa-af2e-234dc6768a07%40postgrespro.ru Reported-by: Tom Lane Author: Andrei Lepikhov Reviewed-by: Alexander Korotkov, Pavel Borisov
1 parent 199012a commit 91143c0

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/backend/optimizer/path/pathkeys.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,34 @@ get_useful_group_keys_orderings(PlannerInfo *root, Path *path)
561561
}
562562
}
563563

564+
#ifdef USE_ASSERT_CHECKING
565+
{
566+
PathKeyInfo *pinfo = linitial_node(PathKeyInfo, infos);
567+
ListCell *lc;
568+
569+
/* Test consistency of info structures */
570+
for_each_from(lc, infos, 1)
571+
{
572+
ListCell *lc1,
573+
*lc2;
574+
575+
info = lfirst_node(PathKeyInfo, lc);
576+
577+
Assert(list_length(info->clauses) == list_length(pinfo->clauses));
578+
Assert(list_length(info->pathkeys) == list_length(pinfo->pathkeys));
579+
Assert(list_difference(info->clauses, pinfo->clauses) == NIL);
580+
Assert(list_difference_ptr(info->pathkeys, pinfo->pathkeys) == NIL);
581+
582+
forboth(lc1, info->clauses, lc2, info->pathkeys)
583+
{
584+
SortGroupClause *sgc = lfirst_node(SortGroupClause, lc1);
585+
PathKey *pk = lfirst_node(PathKey, lc2);
586+
587+
Assert(pk->pk_eclass->ec_sortref == sgc->tleSortGroupRef);
588+
}
589+
}
590+
}
591+
#endif
564592
return infos;
565593
}
566594

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy