Branch Coverage

xs/proto_native_parse.c
Criterion Covered Total %
branch 0 670 0.0


line true false branch
11 0 0 if (rc == 0) return 0;
12 0 0 if (rc < 0) return -1;
13 0 0 if (field_num == 0) return 1; /* end marker */
14 0 0 if (field_num == 1) {
18 0 0 if (rc <= 0) return rc;
19 0 0 } else if (field_num == 2) {
23 0 0 if (rc <= 0) return rc;
65 0 0 if (rc == 0) return 0;
66 0 0 if (rc < 0) {
105 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_BLOCK_INFO) {
107 0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
112 0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
114 0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
116 0 0 for (c = 0; c < nc; c++) {
120 0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
122 0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
0 0 if (rc <= 0) _BAIL(rc);
124 0 0 if (bpos >= blen) _BAIL(0);
0 0 if (bpos >= blen) _BAIL(0);
125 0 0 if ((uint8_t)bbuf[bpos]) {
126 0 0 if (decompressed) Safefree(decompressed);
131 0 0 if (nr > 0) {
135 0 0 if (!vals) {
137 0 0 if (col_err || decompressed) {
0 0 if (col_err || decompressed) {
138 0 0 if (decompressed) Safefree(decompressed);
147 0 0 for (j = 0; j < nr; j++) SvREFCNT_dec(vals[j]);
157 0 0 if (!decompressed) pos = bpos;
158 0 0 if (decompressed) Safefree(decompressed);
176 0 0 if (rc == 0) return 0;
177 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed log block"); return -1; }
202 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_BLOCK_INFO) {
204 0 0 if (rc <= 0) _BAIL_LOG(rc);
0 0 if (rc <= 0) _BAIL_LOG(rc);
0 0 if (rc <= 0) _BAIL_LOG(rc);
208 0 0 if (rc <= 0) _BAIL_LOG(rc);
0 0 if (rc <= 0) _BAIL_LOG(rc);
0 0 if (rc <= 0) _BAIL_LOG(rc);
210 0 0 if (rc <= 0) _BAIL_LOG(rc);
0 0 if (rc <= 0) _BAIL_LOG(rc);
0 0 if (rc <= 0) _BAIL_LOG(rc);
215 0 0 if (nc > 0) {
219 0 0 if (nc > (uint64_t)(blen - bpos)) _BAIL_LOG(-1);
0 0 if (nc > (uint64_t)(blen - bpos)) _BAIL_LOG(-1);
220 0 0 Newxz(names, nc, char *);
221 0 0 Newxz(data, nc, SV **);
228 0 0 for (uint64_t c = 0; c < nc; c++) {
231 0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
238 0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
239 0 0 if (bpos >= blen) { err_seen = 0; break; }
240 0 0 if ((uint8_t)bbuf[bpos]) { err_seen = -1; break; }
242 0 0 if (nr > 0) {
247 0 0 if (!vals) { err_seen = col_err ? -1 : 0; break; }
0 0 if (!vals) { err_seen = col_err ? -1 : 0; break; }
253 0 0 if (err_seen == 1) {
258 0 0 for (uint64_t r = 0; r < nr; r++) {
260 0 0 for (uint64_t c = 0; c < nc; c++) {
266 0 0 ENTER; SAVETMPS; PUSHMARK(SP);
267 0 0 EXTEND(SP, 1);
271 0 0 WARN_AND_CLEAR_ERRSV("on_log");
0 0 WARN_AND_CLEAR_ERRSV("on_log");
0 0 WARN_AND_CLEAR_ERRSV("on_log");
0 0 WARN_AND_CLEAR_ERRSV("on_log");
272 0 0 FREETMPS; LEAVE;
273 0 0 if (self->magic == EV_CH_FREED) { destroyed_during_cb = 1; break; }
287 0 0 for (uint64_t c = 0; c < nc; c++) {
288 0 0 if (data && data[c]) {
0 0 if (data && data[c]) {
289 0 0 for (uint64_t r = 0; r < nr; r++) SvREFCNT_dec(data[c][r]);
292 0 0 if (names && names[c]) Safefree(names[c]);
0 0 if (names && names[c]) Safefree(names[c]);
294 0 0 if (data) Safefree(data);
295 0 0 if (names) Safefree(names);
304 0 0 if (check_destroyed(self)) {
306 0 0 } else if (err_seen < 0) {
309 0 0 } else if (err_seen == 0) { /* need more data — do not advance outer_pos */
316 0 0 if (!decompressed) pos = bpos;
320 0 0 if (decompressed) Safefree(decompressed);
332 0 0 PUSHMARK(SP);
333 0 0 EXTEND(SP, 5);
334 0 0 for (i = 0; i < 5; i++) PUSHs(sv_2mortal(newSVuv(pp[i])));
337 0 0 WARN_AND_CLEAR_ERRSV("progress handler");
0 0 WARN_AND_CLEAR_ERRSV("progress handler");
0 0 WARN_AND_CLEAR_ERRSV("progress handler");
0 0 WARN_AND_CLEAR_ERRSV("progress handler");
338 0 0 FREETMPS; LEAVE;
340 0 0 return check_destroyed(self) ? -2 : 0;
351 0 0 if (rc == 0) return 0;
352 0 0 if (rc < 0) {
364 0 0 if (rc == 0) return 0;
365 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed server name"); return -1; }
368 0 0 if (rc == 0) { Safefree(sname); return 0; }
369 0 0 if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server version major"); return -1; }
372 0 0 if (rc == 0) { Safefree(sname); return 0; }
373 0 0 if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server version minor"); return -1; }
376 0 0 if (rc == 0) { Safefree(sname); return 0; }
377 0 0 if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server revision"); return -1; }
379 0 0 CLEAR_STR(self->server_name);
388 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE) {
391 0 0 if (rc == 0) return 0;
392 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed timezone"); return -1; }
393 0 0 CLEAR_STR(self->server_timezone);
397 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME) {
400 0 0 if (rc == 0) return 0;
401 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed display name"); return -1; }
402 0 0 CLEAR_STR(self->server_display_name);
406 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_VERSION_PATCH) {
409 0 0 if (rc == 0) return 0;
410 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed version patch"); return -1; }
429 0 0 if (rc == 0) return 0;
430 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed table name"); return -1; }
455 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_BLOCK_INFO) {
457 0 0 if (rc == 0) {
458 0 0 if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; }
461 0 0 if (rc < 0) { if (decompressed) Safefree(decompressed); *errmsg = safe_strdup("malformed block info"); return -1; }
0 0 if (rc < 0) { if (decompressed) Safefree(decompressed); *errmsg = safe_strdup("malformed block info"); return -1; }
465 0 0 if (rc == 0) {
466 0 0 if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; }
469 0 0 if (rc < 0) { if (decompressed) Safefree(decompressed); *errmsg = safe_strdup("malformed num_cols"); return -1; }
0 0 if (rc < 0) { if (decompressed) Safefree(decompressed); *errmsg = safe_strdup("malformed num_cols"); return -1; }
472 0 0 if (rc == 0) {
473 0 0 if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; }
476 0 0 if (rc < 0) { if (decompressed) Safefree(decompressed); *errmsg = safe_strdup("malformed num_rows"); return -1; }
0 0 if (rc < 0) { if (decompressed) Safefree(decompressed); *errmsg = safe_strdup("malformed num_rows"); return -1; }
479 0 0 if (num_rows == 0) {
481 0 0 if (self->native_state == NATIVE_WAIT_INSERT_META
482 0 0 && (self->insert_data || self->insert_av) && num_cols > 0) {
0 0 && (self->insert_data || self->insert_av) && num_cols > 0) {
0 0 && (self->insert_data || self->insert_av) && num_cols > 0) {
496 0 0 if (num_cols > (uint64_t)(dlen - dpos)) {
497 0 0 if (decompressed) Safefree(decompressed);
501 0 0 Newxz(cnames, num_cols, const char *);
502 0 0 Newxz(cname_lens, num_cols, size_t);
503 0 0 Newxz(ctypes_str, num_cols, const char *);
504 0 0 Newxz(ctype_lens, num_cols, size_t);
505 0 0 Newxz(ctypes, num_cols, col_type_t *);
507 0 0 for (c = 0; c < num_cols; c++) {
510 0 0 if (rc <= 0) {
511 0 0 meta_hard = (rc < 0 || decompressed != NULL);
0 0 meta_hard = (rc < 0 || decompressed != NULL);
517 0 0 if (rc <= 0) {
518 0 0 meta_hard = (rc < 0 || decompressed != NULL);
0 0 meta_hard = (rc < 0 || decompressed != NULL);
525 0 0 if (dpos >= dlen) {
530 0 0 if ((uint8_t)dbuf[dpos]) {
540 0 0 for (c = 0; c < num_cols; c++) if (ctypes[c]) free_col_type(ctypes[c]);
0 0 for (c = 0; c < num_cols; c++) if (ctypes[c]) free_col_type(ctypes[c]);
544 0 0 if (decompressed) Safefree(decompressed);
545 0 0 if (meta_hard) { *errmsg = safe_strdup(meta_err); return -1; }
551 0 0 if (self->insert_av) {
563 0 0 for (c = 0; c < num_cols; c++)
571 0 0 int encode_failed = (!data_pkt && data_pkt_len == (size_t)-1);
0 0 int encode_failed = (!data_pkt && data_pkt_len == (size_t)-1);
574 0 0 CLEAR_INSERT(self);
0 0 CLEAR_INSERT(self);
576 0 0 if (decompressed) Safefree(decompressed);
580 0 0 if (!data_pkt) {
587 0 0 if (encode_failed)
596 0 0 if (try_write(self)) return -2;
602 0 0 if (self->native_state == NATIVE_WAIT_INSERT_META
603 0 0 && (self->insert_data || self->insert_av) && num_cols == 0) {
0 0 && (self->insert_data || self->insert_av) && num_cols == 0) {
0 0 && (self->insert_data || self->insert_av) && num_cols == 0) {
606 0 0 CLEAR_INSERT(self);
0 0 CLEAR_INSERT(self);
608 0 0 if (decompressed) Safefree(decompressed);
618 0 0 if (try_write(self)) return -2;
629 0 0 if (num_cols > 0) {
630 0 0 CLEAR_SV(self->native_col_names);
631 0 0 CLEAR_SV(self->native_col_types);
635 0 0 for (c = 0; c < num_cols; c++) {
640 0 0 if (rc <= 0) {
641 0 0 if (decompressed) Safefree(decompressed);
642 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed cname"); return -1; }
648 0 0 if (rc <= 0) {
649 0 0 if (decompressed) Safefree(decompressed);
650 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed ctype"); return -1; }
656 0 0 if (dpos >= dlen) {
657 0 0 if (decompressed) Safefree(decompressed);
660 0 0 if ((uint8_t)dbuf[dpos]) {
661 0 0 if (decompressed) Safefree(decompressed);
668 0 0 if (decompressed) Safefree(decompressed);
685 0 0 if (num_cols > (uint64_t)(dlen - dpos)) {
686 0 0 if (decompressed) Safefree(decompressed);
690 0 0 Newxz(columns, num_cols, SV**);
691 0 0 Newxz(col_types, num_cols, col_type_t*);
692 0 0 if (named) {
693 0 0 Newxz(cnames, num_cols, const char *);
694 0 0 Newx(cname_lens, num_cols, size_t);
697 0 0 for (c = 0; c < num_cols; c++) {
702 0 0 if (rc == 0) {
703 0 0 if (decompressed) { *errmsg = safe_strdup("truncated cname"); goto data_error; }
706 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed cname"); goto data_error; }
708 0 0 if (named) {
717 0 0 if (c == 0) {
718 0 0 CLEAR_SV(self->native_col_names);
719 0 0 CLEAR_SV(self->native_col_types);
726 0 0 if (rc == 0) {
727 0 0 if (decompressed) { *errmsg = safe_strdup("truncated ctype"); goto data_error; }
730 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed ctype"); goto data_error; }
736 0 0 if (dpos >= dlen) {
737 0 0 if (decompressed) { *errmsg = safe_strdup("truncated custom_ser"); goto data_error; }
740 0 0 if ((uint8_t)dbuf[dpos]) {
747 0 0 if (c == 0 && !self->lc_dicts) {
0 0 if (c == 0 && !self->lc_dicts) {
748 0 0 Newxz(self->lc_dicts, num_cols, SV**);
749 0 0 Newxz(self->lc_dict_sizes, num_cols, uint64_t);
756 0 0 if (!columns[c]) {
757 0 0 if (col_err || decompressed) {
0 0 if (col_err || decompressed) {
769 0 0 if (ptype == SERVER_TOTALS) {
770 0 0 if (!self->native_totals) self->native_totals = newAV();
772 0 0 } else if (ptype == SERVER_EXTREMES) {
773 0 0 if (!self->native_extremes) self->native_extremes = newAV();
776 0 0 if (!self->native_rows) self->native_rows = newAV();
780 0 0 if (named) {
781 0 0 for (r = 0; r < num_rows; r++) {
783 0 0 for (c = 0; c < num_cols; c++) {
784 0 0 if (!hv_store(hv, cnames[c], cname_lens[c], columns[c][r], 0))
790 0 0 for (r = 0; r < num_rows; r++) {
792 0 0 if (num_cols > 0)
794 0 0 for (c = 0; c < num_cols; c++) {
804 0 0 SV *on_data = (ptype == SERVER_DATA) ? peek_cb_on_data(self) : NULL;
805 0 0 if (on_data && self->native_rows) {
0 0 if (on_data && self->native_rows) {
815 0 0 PUSHMARK(SP);
819 0 0 WARN_AND_CLEAR_ERRSV("on_data handler");
0 0 WARN_AND_CLEAR_ERRSV("on_data handler");
0 0 WARN_AND_CLEAR_ERRSV("on_data handler");
0 0 WARN_AND_CLEAR_ERRSV("on_data handler");
820 0 0 FREETMPS; LEAVE;
828 0 0 CLEAR_SV(self->native_rows);
829 0 0 if (check_destroyed(self)) {
830 0 0 if (cnames) Safefree(cnames);
831 0 0 if (cname_lens) Safefree(cname_lens);
832 0 0 for (c = 0; c < num_cols; c++) {
837 0 0 if (decompressed) Safefree(decompressed);
844 0 0 for (c = 0; c < num_cols; c++) {
850 0 0 if (cnames) Safefree(cnames);
851 0 0 if (cname_lens) Safefree(cname_lens);
852 0 0 if (decompressed) Safefree(decompressed);
862 0 0 for (c = 0; c < num_cols; c++) {
863 0 0 if (columns[c]) {
865 0 0 for (j = 0; j < num_rows; j++) {
866 0 0 if (columns[c][j]) SvREFCNT_dec(columns[c][j]);
870 0 0 if (col_types[c]) free_col_type(col_types[c]);
874 0 0 if (cnames) Safefree(cnames);
875 0 0 if (cname_lens) Safefree(cname_lens);
876 0 0 if (decompressed) Safefree(decompressed);
877 0 0 if (*errmsg) {
897 0 0 if (rc == 0) return 0;
898 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception code"); return -1; }
901 0 0 if (rc == 0) return 0;
902 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception name"); return -1; }
905 0 0 if (rc == 0) return 0;
906 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception message"); return -1; }
909 0 0 if (rc == 0) return 0;
910 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception stack"); return -1; }
913 0 0 if (rc == 0) return 0;
914 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception has_nested"); return -1; }
917 0 0 while (has_nested) {
921 0 0 if (rc == 0) return 0;
922 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; }
924 0 0 for (i = 0; i < 3; i++) {
926 0 0 if (rc == 0) return 0;
927 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; }
930 0 0 if (rc == 0) return 0;
931 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; }
949 0 0 int n = (self->server_revision >= DBMS_MIN_REVISION_WITH_PROGRESS_WRITES) ? 5 : 3;
951 0 0 for (i = 0; i < n; i++) {
953 0 0 if (rc == 0) return 0;
954 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; }
959 0 0 if (self->on_progress) {
962 0 0 if (self->progress_period > 0) {
963 0 0 for (i = 0; i < 5; i++) self->progress_acc[i] += pp[i];
965 0 0 if (now - self->progress_last < self->progress_period)
968 0 0 for (i = 0; i < 5; i++) { pp[i] = self->progress_acc[i]; self->progress_acc[i] = 0; }
971 0 0 if (fire_progress_cb(self, pp) < 0) return -2;
981 0 0 for (i = 0; i < 6; i++) {
983 0 0 if (rc == 0) return 0;
984 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; }
996 0 0 for (i = 0; i < 2; i++) {
998 0 0 if (rc == 0) return 0;
999 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed table_columns packet"); return -1; }
1006 0 0 if (self->on_log) {
1011 0 0 if (rc <= 0) return rc;
1018 0 0 if (rc <= 0) return rc;
1027 0 0 if (rc == 0) return 0;
1028 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed timezone_update packet"); return -1; }
1029 0 0 CLEAR_STR(self->server_timezone);
1060 0 0 while (self->recv_len > 0 && self->magic == EV_CH_MAGIC) {
0 0 while (self->recv_len > 0 && self->magic == EV_CH_MAGIC) {
1065 0 0 if (rc == 0) {
1070 0 0 if (rc == -2) {
1075 0 0 if (rc == 4) {
1077 0 0 if (self->native_state == NATIVE_WAIT_HELLO) {
1079 0 0 if (self->server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM) {
1084 0 0 if (try_write(self)) return;
1085 0 0 if (self->send_pos < self->send_len) {
1094 0 0 if (finish_connect(self)) return;
1101 0 0 if (rc == -1) {
1103 0 0 if (self->native_state == NATIVE_WAIT_HELLO) {
1116 0 0 CLEAR_SV(self->native_rows);
1117 0 0 CLEAR_INSERT(self);
0 0 CLEAR_INSERT(self);
1118 0 0 CLEAR_STR(self->insert_err);
1121 0 0 if (self->send_count > 0) self->send_count--;
1125 0 0 if (destroyed) return;
1132 0 0 if (rc == 2) {
1136 0 0 if (self->send_count > 0) self->send_count--;
1143 0 0 if (self->on_progress && self->progress_period > 0) {
0 0 if (self->on_progress && self->progress_period > 0) {
1145 0 0 for (i = 0; i < 5; i++) if (self->progress_acc[i]) { any = 1; break; }
0 0 for (i = 0; i < 5; i++) if (self->progress_acc[i]) { any = 1; break; }
1146 0 0 if (any) {
1150 0 0 if (fire_progress_cb(self, pp) < 0) return;
1154 0 0 if (self->insert_err) {
1157 0 0 CLEAR_SV(self->native_rows);
1160 0 0 if (destroyed) return;
1164 0 0 if (deliver_rows(self, rows)) return;
1172 0 0 if (rc == 3) {
1175 0 0 if (self->ka_in_flight > 0) {
1181 0 0 if (self->send_count > 0) self->send_count--;
1183 0 0 if (deliver_rows(self, rows)) return;