From: | Junwang Zhao <zhjwpku(at)gmail(dot)com> |
---|---|
To: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
Cc: | Peter Smith <smithpb2250(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Propose a new function - list_is_empty |
Date: | 2022-08-17 08:13:45 |
Message-ID: | CAEG8a3JkTKJNsxSEotc3856dqk6jjHu1d8OKeSSsR7FGFS4kQQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
There are some places that add extra parenthesis like here
--- a/src/backend/optimizer/plan/planner.c
+++ b/src/backend/optimizer/plan/planner.c
@@ -3097,7 +3097,7 @@ reorder_grouping_sets(List *groupingsets, List
*sortclause)
GroupingSetData *gs = makeNode(GroupingSetData);
while (list_length(sortclause) > list_length(previous) &&
- list_length(new_elems) > 0)
+ (new_elems != NIL))
{
and here,
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -3408,7 +3408,7 @@ estimate_num_groups_incremental(PlannerInfo
*root, List *groupExprs,
* for normal cases with GROUP BY or DISTINCT, but it is possible for
* corner cases with set operations.)
*/
- if (groupExprs == NIL || (pgset && list_length(*pgset) < 1))
+ if (groupExprs == NIL || (pgset && (*pgset == NIL)))
return 1.0;
Is it necessary to add that extra parenthesis?
On Wed, Aug 17, 2022 at 3:33 PM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
>
> > On 17 Aug 2022, at 03:09, Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> >
> > On Wed, Aug 17, 2022 at 6:34 AM Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> >>
> >>> On 16 Aug 2022, at 16:03, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> >>
> >>> I agree though that while simplifying list_length() calls, I'd lean to using
> >>> explicit comparisons to NIL.
> >>
> >>
> >> Agreed, I prefer that too.
> >>
> >
> > Thanks for the feedback.
> >
> > PSA patch v3 which now uses explicit comparisons to NIL everywhere,
> > and also addresses the other review comments.
>
> From reading, this version of the patch looks good to me.
>
> --
> Daniel Gustafsson https://vmware.com/
>
>
>
--
Regards
Junwang Zhao
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2022-08-17 08:23:16 | Re: Propose a new function - list_is_empty |
Previous Message | Bharath Rupireddy | 2022-08-17 08:01:10 | Re: Generalize ereport_startup_progress infrastructure |