pg: Module rename + more docs

This commit is contained in:
Yorhel 2025-02-11 10:54:01 +01:00
parent ccc2f1dbf0
commit 33fe0d98a8
7 changed files with 186 additions and 101 deletions

View file

@ -56,7 +56,7 @@ static SV *fupg_q(pTHX_ fupg_conn *c, int stflags, const char *query, I32 ax, I3
}
}
return fu_selfobj(st, "FU::PG::st");
return fu_selfobj(st, "FU::Pg::st");
}
static void fupg_st_destroy(fupg_st *st) {
@ -124,15 +124,12 @@ static void fupg_st_prepare(pTHX_ fupg_st *st) {
PQclear(sync);
}
static SV *fupg_st_params(pTHX_ fupg_st *st) {
static SV *fupg_st_param_types(pTHX_ fupg_st *st) {
fupg_st_prepare(aTHX_ st);
int i, nparams = PQnparams(st->describe);
AV *av = newAV_alloc_x(nparams);
for (i=0; i<nparams; i++) {
HV *hv = newHV();
hv_stores(hv, "oid", newSViv(PQparamtype(st->describe, i)));
av_push_simple(av, newRV_noinc((SV *)hv));
}
for (i=0; i<nparams; i++)
av_push_simple(av, newSViv(PQparamtype(st->describe, i)));
return sv_2mortal(newRV_noinc((SV *)av));
}
@ -256,10 +253,8 @@ static void fupg_st_check_dupcols(pTHX_ fupg_st *st, int start) {
for (i=start; i<nfields; i++) {
const char *key = PQfname(r, i);
int len = -strlen(key);
if (hv_exists(hv, key, len)) {
SvREFCNT_dec((SV *)hv);
if (hv_exists(hv, key, len))
fu_confess("Query returns multiple columns with the same name ('%s')", key);
}
hv_store(hv, key, len, &PL_sv_yes, 0);
}
}
@ -359,7 +354,7 @@ static SV *fupg_st_allh(pTHX_ fupg_st *st) {
static SV *fupg_st_flat(pTHX_ fupg_st *st) {
fupg_st_execute(aTHX_ st);
int i, j, nrows = PQntuples(st->result);
AV *av = newAV_alloc_x(nrows);
AV *av = newAV_alloc_x(nrows * st->nfields);
SV *sv = sv_2mortal(newRV_noinc((SV *)av));
for (i=0; i<nrows; i++) {
for (j=0; j<st->nfields; j++)