Re: Improve error message for duplicate labels in enum types - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Improve error message for duplicate labels in enum types
Date
Msg-id 662497.1756836052@sss.pgh.pa.us
Whole thread Raw
In response to Re: Improve error message for duplicate labels in enum types  (Jim Jones <jim.jones@uni-muenster.de>)
Responses Re: Improve error message for duplicate labels in enum types
List pgsql-hackers
Jim Jones <jim.jones@uni-muenster.de> writes:
> LGTM; I'll mark the CF entry as Ready for Committer.

Pushed with some trivial cosmetic adjustments, including the
perhaps-not-so-trivial fix of removing the comment you falsified.

I was concerned about Rahila's upthread worry about the performance
of this approach, but in some quick testing it seemed to add only
barely-noticeable overhead even at 1000 enum labels.  At 10000
labels it's slightly annoying: my machine goes from ~80ms to ~250ms.
But that seems well beyond what anybody would be likely to use,
so I judge it not worth trying to be smarter.

The obvious solution if we did wish to avoid the O(N^2) behavior would
be to qsort the labels and then compare only adjacent ones.  That'd
require a temporary array though, and I'd bet it's actually slower
than this way for normal-sized enums.  Another possibility perhaps is
to apply the check only when there are fewer than say 1000 labels,
reasoning that anything bigger is probably machine-generated anyhow.

            regards, tom lane



pgsql-hackers by date:

Previous
From: Ranier Vilela
Date:
Subject: Re: Avoid use of uninitialized variable (src/pl/plperl/plperl.c)
Next
From: Tom Lane
Date:
Subject: Re: Disabling memory overcommit deemed dangerous