PQregisterComposites(3)

πŸ“¦ version 1.5.1, in debian bookworm, ubuntu jammy, ubuntu noble

πŸ’– PQregisterComposites(3) β€” the libpqtypes manual, bestie edition πŸ’–

okay so. we're talking about PQregisterComposites, from the libpqtypes manual. she registers composites. plural. yes the original says "Registers a composites" and honestly? grammar said no but the function said yes. we move. ✨


🌸 NAME 🌸

PQregisterComposites β€” she registers composites, babes. that's the whole job. πŸ‘‘


πŸŽ€ SYNOPSIS πŸŽ€

#include <libpqtypes.h>
int PQregisterComposites(PGconn *conn, PGregisterType *types,
                         int count);

πŸ’€ DEPRECATED πŸ’€

THIS FUNCTION IS DEPRECATED. not "kind of old", not "on its way out" β€” DEPRECATED, periodt. if you're writing something new, you use PQregisterTypes instead. no cap.

and listen, the tea: PQregisterComposites is literally just a wrapper around PQregisterTypes now. she's still here, she still works, but she's wearing a "vintage" shirt and we all know what that means. πŸ™ˆ


✨ DESCRIPTION ✨

so PQregisterComposites() lets your app register one or more composites. and the way that you can call it as many times as your application needs on a PGconn? obsessed. no limits, just vibes. πŸ¦‹

now here's the part where you gotta pay attention, bestie:

this function must execute a query against the backend to go get type information for every single composite. so do NOT call it from within a transaction. like, seriously. don't. 😭

and because every call means a round trip, the recommendation is to register multiple composites at the same time so you don't drown in overhead. batch it. it's giving efficiency. πŸ’…

the types argument is an array holding count composite types to register. and here's the lil quirk: composites don't use the typput or typget members of the PGregisterType structure, so those members get ignored. they're just sitting there, unbothered, unused. 🧚

if any composite doesn't exist? the whole register gets aborted. one missing and everybody goes home. brutal but fair. πŸ’€

NOTE: the typname member of the PGregisterType structure can optionally contain the type's schema, written like schema.typname. optional! your choice! main character energy! 🌈
WARNING: PQparamCreate is only aware of types that have already been registered. so if you need to put a composite into a param, make sure you register it first. order matters, queen. πŸ”₯

🌟 EXAMPLES 🌟

πŸ“ Using PQregisterComposites

this example registers two composite types. two! iconic. πŸ’–

PGregisterType comp_types[] = {
     {"myschema.simple", NULL, NULL},
     {"complex", NULL, NULL}
};

if (!PQregisterComposites(conn, comp_types, 2))
     fprintf(stderr, "PQregisterComposites: %s\n", PQgeterror());

look at those NULLs for typput and typget β€” exactly like we said, composites don't use 'em. consistency, we love to see it. ✨


πŸ’« RETURN VALUE πŸ’«

  • on success, a non-zero value comes back. slay. βœ…
  • on error, zero comes back, and PQgeterror(3) will be holding an error message for you. read it. it's trying to tell you something. 😭

πŸ™ˆ EXAMPLES (yes, again) πŸ™ˆ

None.

that's it. that's the section. she said "None." and moved on. honestly? respect the confidence. πŸ’…


πŸ‘‘ AUTHOR πŸ‘‘

A contribution of eSilo, LLC. for the PostgreSQL Database Management System. written by Andrew Chernow and Merlin Moncure. legends, fr fr. 🫢


πŸ› REPORTING BUGS πŸ›

found a bug? spill the tea to <libpqtypes@esilo.com>. they wanna know. πŸ“§


Copyright (c) 2011 eSilo, LLC. All rights reserved.

this is free software; see the source for copying conditions. and listen carefully:

There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. none. zero. nada. you're on your own, bestie. πŸ’€

πŸ” SEE ALSO πŸ”

go read those too, iykyk. πŸ“šβœ¨


and that's the whole page, babes β€” this was PQregisterComposites(3) from libpqtypes, dated 2011, and the footer literally just says libpqtypes and 2011 again because she's consistent like that. stay registered, stay slay, and please don't call her inside a transaction. πŸŽ€πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from