Ron Johnson <ronljohnso...@gmail.com> writes:
> On Fri, Jun 7, 2024 at 12:32 AM David G. Johnston <
> david.g.johns...@gmail.com> wrote:
>> I don’t see us adding an error message at this point.

> Me neither.  It just seemed odd.

v14 thinks the argument of --compress must be an integer, and doesn't
really bother with any syntax error checks:

            case 'Z':
                compresslevel = atoi(optarg);
                if (compresslevel < 0 || compresslevel > 9)
                {
                    pg_log_error("invalid compression level \"%s\"", optarg);
                    exit(1);
                }
                break;

In your example, atoi() will return zero and it will sail along with
no compression.  Releases 15 and up have more complex ideas of what
--compress can specify, and seem to syntax-check it much more
thoroughly.

This is a pretty common coding pattern, so I can't get excited
about changing it, especially not in long-stable branches.

                        regards, tom lane


Reply via email to