PQregisterTypes(3)
π PQregisterTypes(3) β the libpqtypes one, bestie π
okay so we're in the libpqtypes Manual and this is PQregisterTypes, and it is literally the function that teaches libpqtypes about your types before anything else can use them. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
PQregisterTypes β registers sub-classes, composites and user-defined types. no cap, that's the whole job description π
πΈ SYNOPSIS πΈ
#include <libpqtypes.h>
int PQregisterTypes(PGconn *conn, int which, PGregisterType *types,
int count, int async);
π¦ DESCRIPTION π¦
So PQregisterTypes() is the vibe check for your types. It lets an app register one or more PQT_SUBCLASS, PQT_COMPOSITE or PQT_USERDEFINED types β and which flavour you're registering is decided by the which argument. that's it, that's the assignment β¨
When which is PQT_COMPOSITE or PQT_USERDEFINED, this function must execute a query against the backend to retrieve type information, which means... yeah, do not call this from inside a transaction. π
lowkey important: it is recommended to register multiple composites at the same time to avoid round trip overhead. batch it, girlie, the network is not your friend π§
The types argument is an array containing count types to register. here's the tea per flavour:
- composites β do not use the
typputortypgetmembers of thePGregisterTypestructure, so those members are ignored. and if any composite does not exist, the register is aborted. π - user-defined types β must set either
typputand/ortypgetfor each type. non-negotiable, bestie. - sub-classes β the
typnamemember of thePGregisterTypestructure must specify an inheritance relationship: ex."myint=int4"wheremyintinherits fromint4. the=is called the inheritance operator π
and the cute part: if both the typput and typget members of the PGregisterType structure are NULL, the type at that element will behave identically to the type it is inheriting from β that's an alias π. otherwise, the base type's put and/or get routines get overridden.
The async argument indicates if the asynchronous type registration should be used. when it's non-zero, the caller must proceed in the normal async libpq fashion (PQconsumeInput, PQisBusy, PQgetResult) and provide a PGresult to PQregisterResult when obtained to complete the registration. main character async energy, fr fr π
NOTE: thetypnamemember of thePGregisterTypestructure can optionally contain the type's schema:schema.typname. β¨
WARNING: PQparamCreate is only aware of types that have already been registered. if you need to put a type into a param, make sure it is first registered. otherwise you're gonna have a bad time π
π EXAMPLES π
π Using PQregisterTypes
this example registers two composite types. iconic.
PGregisterType comp_types[] = {
{"myschema.simple", NULL, NULL},
{"complex", NULL, NULL}
};
if (!PQregisterTypes(conn, PQT_COMPOSITE, comp_types, 2, 0))
fprintf(stderr, "PQregisterTypes: %s\n", PQgeterror());
β RETURN VALUE β
On success, PQregisterTypes returns a non-zero value π. On error, zero is returned and PQgeterror(3) will contain an error message. check it, always, bestie π
π EXAMPLES π
None.
yes it's a second EXAMPLES section and yes it says "None." β the manpage said it, not me, I don't make the rules π
π AUTHOR π
A contribution of eSilo, LLC. for the PostgreSQL Database Management System. Written by Andrew Chernow. king behaviour π«Ά
πΈ REPORTING BUGS πΈ
Report bugs to <libpqtypes@esilo.com>. be nice, be specific, include the receipts π
π COPYRIGHT π
Copyright (c) 2011 eSilo, LLC. All rights reserved.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
π¦ SEE ALSO π¦
go read them, iykyk π₯
okay bestie that's the whole page, and this was libpqtypes, dated 2011, and it's the PQregisterTypes(3) page β slay, register your types, stay out of transactions, periodt π
β¨π¦
π¦ 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