-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Use case: Our database has tables with some columns of enum types. We use enums as an alternative to text or similar in cases where the set of possible values is finite and relatively small. We do not need support for array-of-enum types. <- this gets you out of the business of having to support an interface where users tell the library what the machine-generated pg_enum.enumtypid OIDs for each enum type are.
It would be nice to be able to serialize JS values to their binary format for use in a copy-from operation. Encoding-wise it looks like enum variants ("labels") are case-sensitive strings, so a suitable JS encoding may be string. Looking at pg_enum and pg_type, it looks like enum variants all use enum_send and enum_recv for typsend and typrecv. Those, in turn, haven't changed between Postgres 12 and 13:
Looks like in terms of send and recv, the only information present on the wire is the label, which is just a string of length < NAMEDATALEN, which docs say
The length of an enum value's textual label is limited by the NAMEDATALEN setting compiled into PostgreSQL; in standard builds this means at most 63 bytes.
So perhaps this would be relatively straightforward to support? Might be very similar to text. My C++ isn't very strong so I'm unsure precisely what the code would look like in JS.