PQgeterror(3)
π PQgeterror(3) β libpqtypes Manual π
okay bestie, so this is the libpqtypes error system page. like, the whole little family of functions that handle errors in libpqtypes. sit down, hydrate, let's go π«Ά
β¨ NAME β¨
PQgeterror, PQseterror, PQgetErrorField β the libpqtypes error system management functions. that's the trio. the error girlies. the whole friend group π
β¨ SYNOPSIS β¨
#include <libpqtypes.h>
char *PQgeterror(void);
void PQseterror(const char *format, ...);
char *PQgetErrorField(int fieldcode);
look at them. so neat. so iconic. β
β¨ DESCRIPTION β¨
so, the tea: the libpqtypes library keeps a per-thread global error message. like every thread gets its own lil error journal, no sharing, no drama. πβ¨ and that error message is managed by PQgeterror() and PQseterror().
PQseterror() takes a regular printf compatible format string β yes, the normal printf kind you already know and love β and uses it to set the libpqtypes error message. π
PQgetErrorField() gets an error field from the last executed query. and okay this part matters, don't skip it: the error field is only set by PQparamExec and PQparamExecPrepared. that's it. that's the only way. so if you're using libpq functions that return results, like PQexec, then keep using PQresultErrorField like you always did. don't come to PQgetErrorField() for those, it won't have your answer, and honestly that's not its job. π
and when you want to clear the libpqtypes error message? call PQseterror() with a NULL format string:
PQseterror(NULL);
boom. cleared. β¨ and lowkey highkey important: this will also clear error fields. two birds, one iconic little function call. π¦
β¨ RETURN VALUE β¨
PQgeterror() returns the last error message for the calling thread. and bestie, listen β it will never return NULL. never ever. it always has something to say. π
PQgetErrorField() returns the error field, referenced by fieldcode, for the last executed query. if no value exists, it returns NULL. so like, sometimes it's quiet. that's valid. πΈ
β¨ EXAMPLES β¨
None.
yeah. that's the whole section. the manpage said None and we respect that. no examples today, go write your own, main character. π
β¨ AUTHOR β¨
a contribution of eSilo, LLC. for the PostgreSQL Database Management System. written by Andrew Chernow and Merlin Moncure. absolute legends, we stan. π«Άπ
β¨ REPORTING BUGS β¨
found a bug? report it to <libpqtypes@esilo.com>. tell them everything. they wanna know. ππ
β¨ 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.
no warranty bestie. literally none. not even the merchantability one. not even the fitness-for-a-particular-purpose one. it's giving "you're on your own" but make it legal. π
β¨ SEE ALSO β¨
pqt-specs(3)π
and that's the page!! π this is PQgeterror(3) from the libpqtypes manual, dated 2011. go forth and handle your errors, you gorgeous little thread. no cap. β¨ππ¦
π¦ 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