PQregisterUserDefinedTypes(3)
π PQregisterUserDefinedTypes(3) π
okay bestie, so this one is a page from the libpqtypes Manual and it's about registering your very own custom types. let's get into it β¨
πΈ NAME πΈ
PQregisterUserDefinedTypes β registers a user-defined types. yes, that's the actual name, and yes, it's the one that makes your custom backend types play nice with libpqtypes π
β¨ SYNOPSIS β¨
#include <libpqtypes.h>
int PQregisterUserDefinedTypes(PGconn *conn, PGregisterType *types,
int count);
π DEPRECATED π
okay so, THIS FUNCTION IS DEPRECATED. like, officially. if you're starting something new, bestie, you should be using PQregisterTypes instead. the way that this one is literally just a wrapper around PQregisterTypes now... it's giving legacy code energy π
π¦ DESCRIPTION π¦
so PQregisterUserDefinedTypes() is the function that lets your app register one or more user-defined types at runtime. and what even is a user-defined type, you ask? it's a custom type over in the backend that implements its own C procedures for in/out/send/recv. very main character of it tbh π
okay important thing: this function must execute a query against the backend to go fetch the type information for each user-defined type. so do not call this from within a transaction. and also, the more types you register in one go, the better β register multiple types at the same time to avoid round trip overhead. one trip, many types, that's the vibe π
so the types argument is an array containing count user-defined types to register. if any type does not exist, the register is aborted β no partial slay, it's all or nothing. and either typput and/or typget must be specified for each type in the types array. no exceptions, no cap.
NOTE: thetypnamemember of thePGregisterTypestructure can optionally contain the type's schema, written likeschema.typnameπ
WARNING: PQparamCreate is only aware of types that have already been registered. so if you need to put a type into a param, make sure it is first registered. register first, param later, that's the order, periodt π
π User-defined Types Registration π
here's an example that registers two user-defined types:
PGregisterType types[] = {
{"graphics.rgb", rgb_put, rgb_get},
{"graphics.digon", digon_put, digon_get}
};
if (!PQregisterUserDefinedTypes(conn, types, 2))
fprintf(stderr, "PQregisterUserDefinedTypes: %s\n", PQgeterror());
look at that. two types. one call. iconic π₯
π«Ά RETURN VALUE π«Ά
- on success, a non-zero value is returned β¨
- on error, zero is returned, and
PQgeterror(3)will contain an error message. so if you get a zero, go checkPQgeterror(3), she'll tell you what went wrong π
π EXAMPLES π
None.
(not me giving you literally nothing here. the manpage said None and I'm being honest about it π)
π AUTHOR π
a contribution of eSilo, LLC. for the PostgreSQL Database Management System. written by Andrew Chernow and Merlin Moncure. absolute legends, fr fr π
π REPORTING BUGS π
found a bug? report it to <libpqtypes@esilo.com>. they wanna hear about it, bestie π
β COPYRIGHT β
Copyright (c) 2011 eSilo, LLC. All rights reserved.
this is free software; see the source for copying conditions. and listen β there is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. so like, no promises, babes π
πΈ SEE ALSO πΈ
and that's the whole page, bestie π this was libpqtypes, dated 2011, and we did it for PQregisterUserDefinedTypes(3). mwah, go register something cute πβ¨π¦
π¦ where this page comes from
- debian bookworm: libpqtypes-dev 1.5.1-9
- ubuntu jammy: libpqtypes-dev 1.5.1-7
- ubuntu noble: libpqtypes-dev 1.5.1-9.1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms