registerCodec

fun registerCodec(codec: TypeCodec<*>)

Registers a custom TypeCodec for encoding and decoding database types at the lowest level.

What the codec declares decides what it binds to. Naming a pgTypeName and a pgSchema binds it to that one type. Naming a pgTypeName and no schema binds it to every type of that name in the catalog, whichever schema they are in, and the OID a parameter goes out as is resolved in flight against the session's search path - which is what makes one codec serve the same type defined per tenant schema. Declaring an oid binds it to that number and nothing else, which is the brittle one: a type dropped and recreated has a new OID, and the codec is then bound to a number the catalog no longer describes.

A schema-qualified type this database does not have is refused here, where the call that named it is still on the stack. A catalog reload that later leaves a registered codec bound to nothing does not raise - the database having changed is not the registration's fault - but it does say so at warn.

Parameters

codec

The codec instance to register.

Throws

TYPE_NOT_FOUND where codec names a schema-qualified type the catalog does not describe.

INVALID_ARGUMENT where codec declares OID 0, which no type has.