pg: Module rename + more docs
This commit is contained in:
parent
ccc2f1dbf0
commit
33fe0d98a8
7 changed files with 186 additions and 101 deletions
13
c/pgconn.c
13
c/pgconn.c
|
|
@ -37,7 +37,7 @@ static SV *fupg_conn_errsv(PGconn *conn, const char *action) {
|
|||
hv_stores(hv, "action", newSVpv(action, 0));
|
||||
hv_stores(hv, "severity", newSVpvs("FATAL")); /* Connection-related errors are always fatal */
|
||||
hv_stores(hv, "message", newSVpv(PQerrorMessage(conn), 0));
|
||||
return fu_croak_hv(hv, "FU::PG::error", "FATAL: %s", PQerrorMessage(conn));
|
||||
return fu_croak_hv(hv, "FU::Pg::error", "FATAL: %s", PQerrorMessage(conn));
|
||||
}
|
||||
|
||||
__attribute__((noreturn))
|
||||
|
|
@ -89,8 +89,8 @@ static void fupg_result_croak(PGresult *r, const char *action, const char *query
|
|||
|
||||
PQclear(r);
|
||||
croak_sv(verbose
|
||||
? fu_croak_hv(hv, "FU::PG::error", "%s", SvPV_nolen(*hv_fetchs(hv, "verbose_message", 0)))
|
||||
: fu_croak_hv(hv, "FU::PG::error", "%s: %s",
|
||||
? fu_croak_hv(hv, "FU::Pg::error", "%s", SvPV_nolen(*hv_fetchs(hv, "verbose_message", 0)))
|
||||
: fu_croak_hv(hv, "FU::Pg::error", "%s: %s",
|
||||
SvPV_nolen(*hv_fetchs(hv, "severity", 0)),
|
||||
SvPV_nolen(*hv_fetchs(hv, "message", 0))
|
||||
)
|
||||
|
|
@ -121,6 +121,7 @@ static void fupg_exec_ok(pTHX_ fupg_conn *c, const char *sql) {
|
|||
/* Connection & transaction handling */
|
||||
|
||||
static SV *fupg_connect(pTHX_ const char *str) {
|
||||
if (!PQconnectdb) fupg_load();
|
||||
PGconn *conn = PQconnectdb(str);
|
||||
if (PQstatus(conn) != CONNECTION_OK) {
|
||||
SV *sv = fupg_conn_errsv(conn, "connect");
|
||||
|
|
@ -135,7 +136,7 @@ static SV *fupg_connect(pTHX_ const char *str) {
|
|||
c->ntypes = 0;
|
||||
c->types = NULL;
|
||||
fustr_init(&c->buf, NULL, SIZE_MAX);
|
||||
return fu_selfobj(c, "FU::PG::conn");
|
||||
return fu_selfobj(c, "FU::Pg::conn");
|
||||
}
|
||||
|
||||
static const char *fupg_conn_status(fupg_conn *c) {
|
||||
|
|
@ -169,7 +170,7 @@ static SV *fupg_conn_txn(pTHX_ fupg_conn *c) {
|
|||
t->stflags = c->stflags;
|
||||
strcpy(t->rollback_cmd, "ROLLBACK");
|
||||
SvREFCNT_inc(c->self);
|
||||
return fu_selfobj(t, "FU::PG::txn");
|
||||
return fu_selfobj(t, "FU::Pg::txn");
|
||||
}
|
||||
|
||||
static SV *fupg_txn_txn(pTHX_ fupg_txn *t) {
|
||||
|
|
@ -185,7 +186,7 @@ static SV *fupg_txn_txn(pTHX_ fupg_txn *t) {
|
|||
n->stflags = t->stflags;
|
||||
snprintf(n->rollback_cmd, sizeof(n->rollback_cmd), "ROLLBACK TO SAVEPOINT fupg_%"UVuf, cookie);
|
||||
SvREFCNT_inc(t->self);
|
||||
return fu_selfobj(n, "FU::PG::txn");
|
||||
return fu_selfobj(n, "FU::Pg::txn");
|
||||
}
|
||||
|
||||
static const char *fupg_txn_status(fupg_txn *t) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue