Re: Add sanity check for duplicate enum values in GUC definitions

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add sanity check for duplicate enum values in GUC definitions
Date: 2025-12-18 07:43:34
Message-ID: b1f7761d-0af3-423b-b1f2-4cfb04f83862@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 18.12.25 01:22, Chao Li wrote:
>> On Dec 17, 2025, at 22:51, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>> On 15.12.25 10:16, Chao Li wrote:
>>> The motivation for this patch comes from my own experience. While working on [1]. I added an enum-typed GUC and made a copy-and-paste mistake, assigning the same numeric value to two different enum entries. This resulted in confusing runtime behavior and cost me about an hour to track down.
>>
>> Why do you assign explicit values at all?
>
> Did you mean to say “duplicate” instead of “explicit”?

No, I meant explicit. I didn't find an example in the thread you linked
to, but I suppose you are writing something like

enum foo {
bar = 1,
baz = 2,
};

But why make those assignments at all. You could just write

enum foo {
bar,
baz,
};

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andreas Karlsson 2025-12-18 07:51:27 Re: [PATCH] Documentation
Previous Message Nazir Bilal Yavuz 2025-12-18 07:35:44 Re: Speed up COPY FROM text/CSV parsing using SIMD