Branch Coverage

c/pgst.c
Criterion Covered Total %
branch 0 256 0.0


line true false branch
31 0 0 if (!st->conn->trace) return;
37 0 0 PUSHMARK(SP);
38 0 0 mXPUSHs(sv_bless(newRV_inc(st->self), gv_stashpv("FU::Pg::st", GV_ADD)));
42 0 0 FREETMPS;
53 0 0 if (!r) fupg_conn_croak(c, "exec");
54 0 0 switch (PQresultStatus(r)) {
62 0 0 if (c->trace) {
87 0 0 if (argc > 2) {
90 0 0 for (i=2; i < argc; i++) {
103 0 0 if (st->prep) {
105 0 0 } else if (st->prepared) {
111 0 0 for (i=0; i < st->nbind; i++) SvREFCNT_dec(st->bind[i]);
116 0 0 if (st->recv) for (i=0; infields; i++) fupg_tio_free(st->recv + i);
0 0 if (st->recv) for (i=0; infields; i++) fupg_tio_free(st->recv + i);
125 0 0 if (st->describe) return;
126 0 0 if (st->prepared) fu_confess("invalid attempt to re-prepare invalid statement");
127 0 0 if (st->result) fu_confess("invalid attempt to prepare already executed statement");
129 0 0 if (st->stflags & FUPG_CACHE)
131 0 0 if (st->prep && st->prep->describe) {
0 0 if (st->prep && st->prep->describe) {
139 0 0 if (st->prep) st->prep->name = st->conn->prep_counter;
155 0 0 if (!prep) {
159 0 0 if (PQresultStatus(prep) != PGRES_COMMAND_OK) {
170 0 0 if (!desc) {
174 0 0 if (PQresultStatus(desc) != PGRES_COMMAND_OK) {
178 0 0 if (st->prep) st->prep->describe = desc;
181 0 0 if (!sync) fupg_conn_croak(st->conn , "prepare");
182 0 0 if (PQresultStatus(sync) != PGRES_PIPELINE_SYNC)
188 0 0 if (st->result && !st->describe)
0 0 if (st->result && !st->describe)
192 0 0 AV *av = nparams == 0 ? newAV() : newAV_alloc_x(nparams);
193 0 0 for (i=0; i
200 0 0 AV *av = st->nbind == 0 ? newAV() : newAV_alloc_x(st->nbind);
201 0 0 for (i=0; inbind; i++)
208 0 0 if (!r) {
213 0 0 AV *av = nfields == 0 ? newAV() : newAV_alloc_x(nfields);
214 0 0 for (i=0; i
220 0 0 if (tmod >= 0) hv_stores(hv, "typemod", newSViv(tmod));
229 0 0 if (st->stflags & FUPG_TEXT_PARAMS) {
230 0 0 for (i=0; inbind; i++)
231 0 0 st->param_values[i] = !SvOK(st->bind[i]) ? NULL : SvPVutf8_nolen(st->bind[i]);
236 0 0 buf->cur = fustr_start(buf);
240 0 0 for (i=0; inbind; i++) {
241 0 0 if (!SvOK(st->bind[i])) {
248 0 0 off = fustr_len(buf);
253 0 0 st->param_lengths[i] = fustr_len(buf) - off;
259 0 0 buf->cur = fustr_start(buf);
260 0 0 for (i=0; inbind; i++) {
261 0 0 if (st->param_values[i]) {
272 0 0 if (st->result) fu_confess("Invalid attempt to execute statement multiple times");
275 0 0 int direct = !st->describe && (st->nbind == 0 || st->stflags & FUPG_TEXT_PARAMS) && !(st->stflags & FUPG_CACHE);
0 0 int direct = !st->describe && (st->nbind == 0 || st->stflags & FUPG_TEXT_PARAMS) && !(st->stflags & FUPG_CACHE);
0 0 int direct = !st->describe && (st->nbind == 0 || st->stflags & FUPG_TEXT_PARAMS) && !(st->stflags & FUPG_CACHE);
0 0 int direct = !st->describe && (st->nbind == 0 || st->stflags & FUPG_TEXT_PARAMS) && !(st->stflags & FUPG_CACHE);
276 0 0 if (!direct) {
278 0 0 if (PQnparams(st->describe) != st->nbind)
301 0 0 ) : PQexecPrepared(st->conn->conn,
311 0 0 if (!r) fupg_conn_croak(st->conn , "exec");
312 0 0 switch (PQresultStatus(r)) {
322 0 0 for (i=0; infields; i++)
332 0 0 if (PQgetisnull(r, row, col)) return newSV(0);
342 0 0 for (i=start; i
345 0 0 if (hv_exists(hv, key, len))
363 0 0 if (st->nfields > 1) fu_confess("Invalid use of $st->val() on query returning more than one column");
364 0 0 if (st->nfields == 0) fu_confess("Invalid use of $st->val() on query returning no data");
365 0 0 if (PQntuples(st->result) > 1) fu_confess("Invalid use of $st->val() on query returning more than one row");
366 0 0 SV *sv = PQntuples(st->result) == 0 ? newSV(0) : fupg_st_getval(aTHX_ st, 0, 0);
373 0 0 if (PQntuples(st->result) > 1) fu_confess("Invalid use of $st->rowl() on query returning more than one row");
374 0 0 int nfields = PQntuples(st->result) == 0 ? 0 : st->nfields;
375 0 0 if (GIMME_V != G_LIST) {
380 0 0 EXTEND(SP, nfields);
0 0 EXTEND(SP, nfields);
382 0 0 for (i=0; i
388 0 0 if (PQntuples(st->result) > 1) fu_confess("Invalid use of $st->rowl() on query returning more than one row");
389 0 0 if (PQntuples(st->result) == 0) return &PL_sv_undef;
390 0 0 AV *av = st->nfields == 0 ? newAV() : newAV_alloc_x(st->nfields);
393 0 0 for (i=0; infields; i++) av_push_simple(av, fupg_st_getval(aTHX_ st, 0, i));
400 0 0 if (PQntuples(st->result) > 1) fu_confess("Invalid use of $st->rowh() on query returning more than one row");
401 0 0 if (PQntuples(st->result) == 0) return &PL_sv_undef;
405 0 0 for (i=0; infields; i++) {
415 0 0 AV *av = nrows == 0 ? newAV() : newAV_alloc_x(nrows);
417 0 0 for (i=0; i
418 0 0 AV *row = st->nfields == 0 ? newAV() : newAV_alloc_x(st->nfields);
420 0 0 for (j=0; jnfields; j++)
430 0 0 AV *av = nrows == 0 ? newAV() : newAV_alloc_x(nrows);
432 0 0 for (i=0; i
435 0 0 for (j=0; jnfields; j++) {
446 0 0 AV *av = nrows == 0 || st->nfields == 0 ? newAV() : newAV_alloc_x(nrows * st->nfields);
0 0 AV *av = nrows == 0 || st->nfields == 0 ? newAV() : newAV_alloc_x(nrows * st->nfields);
448 0 0 for (i=0; i
449 0 0 for (j=0; jnfields; j++)
457 0 0 if (st->nfields > 2) fu_confess("Invalid use of $st->kvv() on query returning more than two columns");
458 0 0 if (st->nfields == 0) fu_confess("Invalid use of $st->kvv() on query returning no data");
462 0 0 for (i=0; i
465 0 0 if (hv_exists_ent(hv, key, 0)) fu_confess("Key '%s' is duplicated in $st->kvv() query results", SvPV_nolen(key));
466 0 0 hv_store_ent(hv, key, st->nfields == 1 ? newSV_true() : fupg_st_getval(aTHX_ st, i, 1), 0);
467 0 0 FREETMPS;
474 0 0 if (st->nfields == 0) fu_confess("Invalid use of $st->kva() on query returning no data");
478 0 0 for (i=0; i
481 0 0 if (hv_exists_ent(hv, key, 0)) fu_confess("Key '%s' is duplicated in $st->kva() query results", SvPV_nolen(key));
482 0 0 AV *row = st->nfields == 1 ? newAV() : newAV_alloc_x(st->nfields-1);
484 0 0 FREETMPS;
485 0 0 for (j=1; jnfields; j++)
494 0 0 if (st->nfields == 0) fu_confess("Invalid use of $st->kvh() on query returning no data");
498 0 0 for (i=0; i
501 0 0 if (hv_exists_ent(hv, key, 0)) fu_confess("Key '%s' is duplicated in $st->kvh() query results", SvPV_nolen(key));
504 0 0 FREETMPS;
505 0 0 for (j=1; jnfields; j++) {
530 0 0 if (!r) fupg_conn_croak(c, "exec");
532 0 0 switch (s) {
550 0 0 const char *buf = c->bin ? SvPVbyte(data, len) : SvPVutf8(data, len);
551 0 0 if (PQputCopyData(c->conn->conn, buf, len) < 0) fupg_conn_croak(c->conn, "copy");
557 0 0 if (len == -1) {
560 0 0 } else if (len < 0) {
561 0 0 if (discard) c->rddone = 1;
564 0 0 SV *r = discard ? &PL_sv_undef : newSVpvn_flags(buf, len, SVs_TEMP | (c->bin ? 0 : SVf_UTF8));
0 0 SV *r = discard ? &PL_sv_undef : newSVpvn_flags(buf, len, SVs_TEMP | (c->bin ? 0 : SVf_UTF8));
570 0 0 if (c->closed) return;
573 0 0 if (c->in && PQputCopyEnd(c->conn->conn, NULL) < 0 && !ignerror)
0 0 if (c->in && PQputCopyEnd(c->conn->conn, NULL) < 0 && !ignerror)
0 0 if (c->in && PQputCopyEnd(c->conn->conn, NULL) < 0 && !ignerror)
576 0 0 while (!c->in && !c->rddone) fupg_copy_read(aTHX_ c, 1);
0 0 while (!c->in && !c->rddone) fupg_copy_read(aTHX_ c, 1);
579 0 0 if (!ignerror && !r) fupg_conn_croak(c->conn, "copyEnd");
0 0 if (!ignerror && !r) fupg_conn_croak(c->conn, "copyEnd");
580 0 0 if (!ignerror && PQresultStatus(r) != PGRES_COMMAND_OK) fupg_result_croak(r, "copy", "");
0 0 if (!ignerror && PQresultStatus(r) != PGRES_COMMAND_OK) fupg_result_croak(r, "copy", "");
583 0 0 while ((r = PQgetResult(c->conn->conn))) PQclear(r);