From: | Daniel Gustafsson <daniel(at)yesql(dot)se> |
---|---|
To: | Peter Smith <smithpb2250(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Propose a new function - list_is_empty |
Date: | 2022-08-16 08:39:36 |
Message-ID: | 545E0AB4-7B84-4DDB-A44D-1F8C641187B9@yesql.se |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On 16 Aug 2022, at 07:29, Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
> On Tue, Aug 16, 2022 at 11:27 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> if you want to get rid of overcomplicated uses of
>> list_length() in favor of one of those spellings, have at it.
>
> Done, and tested OK with make check-world.
I think these are nice cleanups to simplify and streamline the code, just a few
small comments from reading the patch:
/* If no subcommands, don't collect */
- if (list_length(currentEventTriggerState->currentCommand->d.alterTable.subcmds) != 0)
+ if (currentEventTriggerState->currentCommand->d.alterTable.subcmds)
Here the current coding gives context about the data structure used for the
subcmds member which is now lost. I don't mind the change but rewording the
comment above to indicate that subcmds is a list would be good IMHO.
- build_expressions = (list_length(stxexprs) > 0);
+ build_expressions = stxexprs != NIL;
Might be personal taste, but I think the parenthesis should be kept here as a
visual aid for the reader.
- Assert(list_length(publications) > 0);
+ Assert(publications);
The more common (and clearer IMO) pattern would be Assert(publications != NIL);
I think. The same applies for a few hunks in the patch.
- Assert(clauses != NIL);
- Assert(list_length(clauses) >= 1);
+ Assert(clauses);
Just removing the list_length() assertion would be enough here.
makeIndexArray() in jsonpath_gram.y has another Assert(list_length(list) > 0);
construction as well. The other I found is in create_groupingsets_path() but
there I think it makes sense to keep the current coding based on the assertion
just prior to it being very similar and requiring list_length().
--
Daniel Gustafsson https://vmware.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2022-08-16 08:45:30 | Re: [PG15 Doc] remove "tty" connect string from manual |
Previous Message | David Rowley | 2022-08-16 08:26:41 | Re: [PoC] Reducing planning time when tables have many partitions |