Correct type of front_pathkey to PathKey
authorTomas Vondra <tomas.vondra@postgresql.org>
Sun, 23 Jan 2022 02:36:55 +0000 (03:36 +0100)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sun, 23 Jan 2022 02:53:18 +0000 (03:53 +0100)
In sort_inner_and_outer we iterate a list of PathKey elements, but the
variable is declared as (List *). This mistake is benign, because we
only pass the pointer to lcons() and never dereference it.

This exists since ~2004, but it's confusing. So fix and backpatch to all
supported branches.

Backpatch-through: 10
Discussion: https://postgr.es/m/bf3a6ea1-a7d8-7211-0669-189d5c169374%40enterprisedb.com

src/backend/optimizer/path/joinpath.c

index f96fc9fd282eebe9d22efd610d4a81afb5691c3a..9a8c5165b0451c57bfee124c4cbff83d8c0efee2 100644 (file)
@@ -1258,7 +1258,7 @@ sort_inner_and_outer(PlannerInfo *root,
 
    foreach(l, all_pathkeys)
    {
-       List       *front_pathkey = (List *) lfirst(l);
+       PathKey    *front_pathkey = (PathKey *) lfirst(l);
        List       *cur_mergeclauses;
        List       *outerkeys;
        List       *innerkeys;