Pg-PQ
view release on metacpan or search on metacpan
OUTPUT:
RETVAL
MODULE = Pg::PQ PACKAGE = Pg::PQ::Conn PREFIX=PQ
void
PQdefaults(...)
PREINIT:
PQconninfoOption *opts;
int n = 0;
PPCODE:
opts = PQconndefaults();
if (opts) {
for (; opts[n].keyword; n++) {
HV *hv = newHV();
XPUSHs(newRV_noinc((SV*)hv));
hv_stores(hv, "keyword" , newSVpv(opts[n].keyword , 0));
hv_stores(hv, "envvar" , newSVpv(opts[n].envvar , 0));
hv_stores(hv, "compiled", newSVpv(opts[n].compiled, 0));
hv_stores(hv, "value" , newSVpv(opts[n].val , 0));
hv_stores(hv, "label" , newSVpv(opts[n].label , 0));
OUTPUT:
RETVAL
# PGcancel *PQgetCancel(PGconn *conn);
# ALIAS:
# makeCancel = 0
void PQnotifies(PGconn *conn)
PREINIT:
PGnotify *notice;
PPCODE:
notice = PQnotifies(conn);
if (notice) {
int pid = notice->be_pid;
SV *name = sv_2mortal(my_newSVpv_utf8(aTHX_ notice->relname));
SV *extra = sv_2mortal(my_newSVpv_utf8(aTHX_ notice->extra));
PQfreemem(notice);
EXTEND(sp, 3);
PUSHs(name);
if (GIMME_V == G_ARRAY) {
PUSHs(sv_2mortal(newSViv(pid)));
char *PQfname(PGresult *res, int column_number)
ALIAS:
columnName = 0
void
PQfnames(PGresult *res)
ALIAS:
columnNames = 0
PREINIT:
int cols;
PPCODE:
cols = PQnfields(res);
if (cols) {
int j;
if (GIMME_V != G_ARRAY) cols = 1;
EXTEND(sp, cols);
for (j = 0; j < cols; j++) {
char *pv = PQfname(res, j);
SV *sv = newSVpvn_utf8(pv, strlen(pv), 1);
mPUSHs(sv);
}
}
OUTPUT:
RETVAL
void
PQgettuple(PGresult *res, UV i = 0)
ALIAS:
row = 0
PREINIT:
int rows, cols, j;
PPCODE:
rows = PQntuples(res);
cols = PQnfields(res);
if ((i > rows) || !cols)
XSRETURN(0);
else {
if (GIMME_V != G_ARRAY) cols = 1;
EXTEND(SP, cols);
for (j = 0; j < cols; j++) {
if (!PQgetisnull(res, i, j)) {
char *pv = PQgetvalue(res, i, j);
}
XSRETURN(cols);
}
void
PQgettuple_as_hash(PGresult *res, ...)
ALIAS:
rowAsHash = 0
PREINIT:
int i, rows, cols;
PPCODE:
i = (items > 1 ? SvIV(ST(1)) : 0);
rows = PQntuples(res);
cols = PQnfields(res);
if ((i > rows) || !cols)
XSRETURN(0);
else {
int j;
HV *hv = newHV();
SV *rv = newRV_noinc((SV*)hv);
SV *tmp = NULL;
mPUSHs(rv);
XSRETURN(1);
}
void
PQgetcolumn(PGresult *res, int j = 0)
ALIAS:
column = 0
PREINIT:
int rows, cols, i;
PPCODE:
rows = PQntuples(res);
cols = PQnfields(res);
if ((j > cols) || !rows)
XSRETURN(0);
else {
if (GIMME_V != G_ARRAY) rows = 1;
EXTEND(SP, rows);
for (i = 0; i < rows; i++) {
if (!PQgetisnull(res, i, j)) {
char *pv = PQgetvalue(res, i, j);
}
XSRETURN(rows);
}
void
PQgettuples(PGresult *res)
ALIAS:
rows = 0
PREINIT:
int rows, cols, i, j;
PPCODE:
rows = PQntuples(res);
cols = PQnfields(res);
if (GIMME_V != G_ARRAY) {
mPUSHi(rows);
XSRETURN(1);
}
else {
EXTEND(SP, rows);
for (i = 0; i < rows; i++) {
AV *av = newAV();
}
XSRETURN(rows);
}
void
PQgettuples_as_hashes(PGresult *res)
ALIAS:
rowsAsHashes = 0
PREINIT:
int rows, cols, i, j;
PPCODE:
rows = PQntuples(res);
cols = PQnfields(res);
if (GIMME_V != G_ARRAY) {
mPUSHi(cols);
XSRETURN(1);
}
else {
SV **names;
Newx(names, cols, SV *);
EXTEND(SP, rows);
XSRETURN(rows);
}
void
PQgetcolumns(PGresult *res)
ALIAS:
columns = 0
PREINIT:
int rows, cols, i, j;
PPCODE:
rows = PQntuples(res);
cols = PQnfields(res);
if (GIMME_V != G_ARRAY) {
mPUSHi(cols);
XSRETURN(1);
}
else {
EXTEND(SP, rows);
for (j = 0; j < cols; j++) {
AV *av = newAV();
( run in 0.583 second using v1.01-cache-2.11-cpan-5511b514fd6 )