Hi, 2013/8/23 <[email protected]>
> Thank you for your reply. > > I think the ordering by oid as a fallback is fine... I assume postgres > generates the oids in the right > order when storing the type, so the effective result will be the same as > using pg_enum.enumsortorder, provided I don't > try to reorder the enum type fiddling with the internals ( adding an > additional enum value is possible > in 9.1., I checked that, but that won't interfere with the order since the > oid is strictly monotonic.... ) > As a matter of fact, I didn't come up with the idea about ordering by oid myself ;-) The strict ordering was guaranteed by PostgreSQL 9.0 documentation: http://www.postgresql.org/docs/9.0/static/catalog-pg-enum.html The OIDs for a particular enum type are guaranteed to be ordered in the way the type should sort, but there is no guarantee about the ordering of OIDs of unrelated enum types. But I got confused about their rather weird "feature upgrade" in 9.1 when they distinguish between even and odd OIDs: http://www.postgresql.org/docs/9.1/static/catalog-pg-enum.html The OIDs for pg_enum rows follow a special rule: even-numbered OIDs are guaranteed to be ordered in the same way as the sort ordering of their enum type. That is, if two even OIDs belong to the same enum type, the smaller OID must have the smaller enumsortorder value. Odd-numbered OID values need bear no relationship to the sort order. I somewhat don't trust that funny distinction. Semantics that has been put on even or odd IDs is about the least expected thing ever in any database :-) When updating the pg_enum.enumorder by hand I'd break even this workaround. > Maybe one should mention in the documentation that this is a bad idea. > What's a bad idea? Reordering enum literals? I suspect that each DDL operation on PostgreSQL enum types will trigger the generation of an entirely new set of enum literals / OIDs. Cheers Lukas -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
