Branch Coverage

xs/proto_native_parse.c
Criterion Covered Total %
branch 0 658 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) {
216 0 0 Newxz(names, nc, char *);
217 0 0 Newxz(data, nc, SV **);
224 0 0 for (uint64_t c = 0; c < nc; c++) {
227 0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
234 0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
0 0 if (rc <= 0) { err_seen = rc < 0 ? -1 : 0; break; }
235 0 0 if (bpos >= blen) { err_seen = 0; break; }
236 0 0 if ((uint8_t)bbuf[bpos]) { err_seen = -1; break; }
238 0 0 if (nr > 0) {
243 0 0 if (!vals) { err_seen = col_err ? -1 : 0; break; }
0 0 if (!vals) { err_seen = col_err ? -1 : 0; break; }
249 0 0 if (err_seen == 1) {
254 0 0 for (uint64_t r = 0; r < nr; r++) {
256 0 0 for (uint64_t c = 0; c < nc; c++) {
262 0 0 ENTER; SAVETMPS; PUSHMARK(SP);
263 0 0 EXTEND(SP, 1);
267 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");
268 0 0 FREETMPS; LEAVE;
269 0 0 if (self->magic == EV_CH_FREED) { destroyed_during_cb = 1; break; }
283 0 0 for (uint64_t c = 0; c < nc; c++) {
284 0 0 if (data && data[c]) {
0 0 if (data && data[c]) {
285 0 0 for (uint64_t r = 0; r < nr; r++) SvREFCNT_dec(data[c][r]);
288 0 0 if (names && names[c]) Safefree(names[c]);
0 0 if (names && names[c]) Safefree(names[c]);
290 0 0 if (data) Safefree(data);
291 0 0 if (names) Safefree(names);
300 0 0 if (check_destroyed(self)) {
302 0 0 } else if (err_seen < 0) {
305 0 0 } else if (err_seen == 0) { /* need more data — do not advance outer_pos */
312 0 0 if (!decompressed) pos = bpos;
316 0 0 if (decompressed) Safefree(decompressed);
328 0 0 PUSHMARK(SP);
329 0 0 EXTEND(SP, 5);
330 0 0 for (i = 0; i < 5; i++) PUSHs(sv_2mortal(newSVuv(pp[i])));
333 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");
334 0 0 FREETMPS; LEAVE;
336 0 0 return check_destroyed(self) ? -2 : 0;
347 0 0 if (rc == 0) return 0;
348 0 0 if (rc < 0) {
360 0 0 if (rc == 0) return 0;
361 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed server name"); return -1; }
364 0 0 if (rc == 0) { Safefree(sname); return 0; }
365 0 0 if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server version major"); 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 minor"); 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 revision"); return -1; }
375 0 0 CLEAR_STR(self->server_name);
384 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE) {
387 0 0 if (rc == 0) return 0;
388 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed timezone"); return -1; }
389 0 0 CLEAR_STR(self->server_timezone);
393 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_SERVER_DISPLAY_NAME) {
396 0 0 if (rc == 0) return 0;
397 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed display name"); return -1; }
398 0 0 CLEAR_STR(self->server_display_name);
402 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_VERSION_PATCH) {
405 0 0 if (rc == 0) return 0;
406 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed version patch"); return -1; }
425 0 0 if (rc == 0) return 0;
426 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed table name"); return -1; }
451 0 0 if (self->server_revision >= DBMS_MIN_REVISION_WITH_BLOCK_INFO) {
453 0 0 if (rc == 0) {
454 0 0 if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; }
457 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; }
461 0 0 if (rc == 0) {
462 0 0 if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; }
465 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; }
468 0 0 if (rc == 0) {
469 0 0 if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; }
472 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; }
475 0 0 if (num_rows == 0) {
477 0 0 if (self->native_state == NATIVE_WAIT_INSERT_META
478 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) {
490 0 0 Newxz(cnames, num_cols, const char *);
491 0 0 Newxz(cname_lens, num_cols, size_t);
492 0 0 Newxz(ctypes_str, num_cols, const char *);
493 0 0 Newxz(ctype_lens, num_cols, size_t);
494 0 0 Newxz(ctypes, num_cols, col_type_t *);
496 0 0 for (c = 0; c < num_cols; c++) {
499 0 0 if (rc <= 0) {
500 0 0 meta_hard = (rc < 0 || decompressed != NULL);
0 0 meta_hard = (rc < 0 || decompressed != NULL);
506 0 0 if (rc <= 0) {
507 0 0 meta_hard = (rc < 0 || decompressed != NULL);
0 0 meta_hard = (rc < 0 || decompressed != NULL);
514 0 0 if (dpos >= dlen) {
519 0 0 if ((uint8_t)dbuf[dpos]) {
529 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]);
533 0 0 if (decompressed) Safefree(decompressed);
534 0 0 if (meta_hard) { *errmsg = safe_strdup(meta_err); return -1; }
540 0 0 if (self->insert_av) {
552 0 0 for (c = 0; c < num_cols; c++)
560 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);
563 0 0 CLEAR_INSERT(self);
0 0 CLEAR_INSERT(self);
565 0 0 if (decompressed) Safefree(decompressed);
569 0 0 if (!data_pkt) {
576 0 0 if (encode_failed)
585 0 0 if (try_write(self)) return -2;
591 0 0 if (self->native_state == NATIVE_WAIT_INSERT_META
592 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) {
595 0 0 CLEAR_INSERT(self);
0 0 CLEAR_INSERT(self);
597 0 0 if (decompressed) Safefree(decompressed);
607 0 0 if (try_write(self)) return -2;
618 0 0 if (num_cols > 0) {
619 0 0 CLEAR_SV(self->native_col_names);
620 0 0 CLEAR_SV(self->native_col_types);
624 0 0 for (c = 0; c < num_cols; c++) {
629 0 0 if (rc <= 0) {
630 0 0 if (decompressed) Safefree(decompressed);
631 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed cname"); return -1; }
637 0 0 if (rc <= 0) {
638 0 0 if (decompressed) Safefree(decompressed);
639 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed ctype"); return -1; }
645 0 0 if (dpos >= dlen) {
646 0 0 if (decompressed) Safefree(decompressed);
649 0 0 if ((uint8_t)dbuf[dpos]) {
650 0 0 if (decompressed) Safefree(decompressed);
657 0 0 if (decompressed) Safefree(decompressed);
672 0 0 Newxz(columns, num_cols, SV**);
673 0 0 Newxz(col_types, num_cols, col_type_t*);
674 0 0 if (named) {
675 0 0 Newxz(cnames, num_cols, const char *);
676 0 0 Newx(cname_lens, num_cols, size_t);
679 0 0 for (c = 0; c < num_cols; c++) {
684 0 0 if (rc == 0) {
685 0 0 if (decompressed) { *errmsg = safe_strdup("truncated cname"); goto data_error; }
688 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed cname"); goto data_error; }
690 0 0 if (named) {
699 0 0 if (c == 0) {
700 0 0 CLEAR_SV(self->native_col_names);
701 0 0 CLEAR_SV(self->native_col_types);
708 0 0 if (rc == 0) {
709 0 0 if (decompressed) { *errmsg = safe_strdup("truncated ctype"); goto data_error; }
712 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed ctype"); goto data_error; }
718 0 0 if (dpos >= dlen) {
719 0 0 if (decompressed) { *errmsg = safe_strdup("truncated custom_ser"); goto data_error; }
722 0 0 if ((uint8_t)dbuf[dpos]) {
729 0 0 if (c == 0 && !self->lc_dicts) {
0 0 if (c == 0 && !self->lc_dicts) {
730 0 0 Newxz(self->lc_dicts, num_cols, SV**);
731 0 0 Newxz(self->lc_dict_sizes, num_cols, uint64_t);
738 0 0 if (!columns[c]) {
739 0 0 if (col_err || decompressed) {
0 0 if (col_err || decompressed) {
751 0 0 if (ptype == SERVER_TOTALS) {
752 0 0 if (!self->native_totals) self->native_totals = newAV();
754 0 0 } else if (ptype == SERVER_EXTREMES) {
755 0 0 if (!self->native_extremes) self->native_extremes = newAV();
758 0 0 if (!self->native_rows) self->native_rows = newAV();
762 0 0 if (named) {
763 0 0 for (r = 0; r < num_rows; r++) {
765 0 0 for (c = 0; c < num_cols; c++) {
766 0 0 if (!hv_store(hv, cnames[c], cname_lens[c], columns[c][r], 0))
772 0 0 for (r = 0; r < num_rows; r++) {
774 0 0 if (num_cols > 0)
776 0 0 for (c = 0; c < num_cols; c++) {
786 0 0 SV *on_data = (ptype == SERVER_DATA) ? peek_cb_on_data(self) : NULL;
787 0 0 if (on_data && self->native_rows) {
0 0 if (on_data && self->native_rows) {
797 0 0 PUSHMARK(SP);
801 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");
802 0 0 FREETMPS; LEAVE;
810 0 0 CLEAR_SV(self->native_rows);
811 0 0 if (check_destroyed(self)) {
812 0 0 if (cnames) Safefree(cnames);
813 0 0 if (cname_lens) Safefree(cname_lens);
814 0 0 for (c = 0; c < num_cols; c++) {
819 0 0 if (decompressed) Safefree(decompressed);
826 0 0 for (c = 0; c < num_cols; c++) {
832 0 0 if (cnames) Safefree(cnames);
833 0 0 if (cname_lens) Safefree(cname_lens);
834 0 0 if (decompressed) Safefree(decompressed);
844 0 0 for (c = 0; c < num_cols; c++) {
845 0 0 if (columns[c]) {
847 0 0 for (j = 0; j < num_rows; j++) {
848 0 0 if (columns[c][j]) SvREFCNT_dec(columns[c][j]);
852 0 0 if (col_types[c]) free_col_type(col_types[c]);
856 0 0 if (cnames) Safefree(cnames);
857 0 0 if (cname_lens) Safefree(cname_lens);
858 0 0 if (decompressed) Safefree(decompressed);
859 0 0 if (*errmsg) {
879 0 0 if (rc == 0) return 0;
880 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception code"); return -1; }
883 0 0 if (rc == 0) return 0;
884 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception name"); return -1; }
887 0 0 if (rc == 0) return 0;
888 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception message"); return -1; }
891 0 0 if (rc == 0) return 0;
892 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception stack"); return -1; }
895 0 0 if (rc == 0) return 0;
896 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed exception has_nested"); return -1; }
899 0 0 while (has_nested) {
903 0 0 if (rc == 0) return 0;
904 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; }
906 0 0 for (i = 0; i < 3; i++) {
908 0 0 if (rc == 0) return 0;
909 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; }
912 0 0 if (rc == 0) return 0;
913 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; }
931 0 0 int n = (self->server_revision >= DBMS_MIN_REVISION_WITH_PROGRESS_WRITES) ? 5 : 3;
933 0 0 for (i = 0; i < n; i++) {
935 0 0 if (rc == 0) return 0;
936 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; }
941 0 0 if (self->on_progress) {
944 0 0 if (self->progress_period > 0) {
945 0 0 for (i = 0; i < 5; i++) self->progress_acc[i] += pp[i];
947 0 0 if (now - self->progress_last < self->progress_period)
950 0 0 for (i = 0; i < 5; i++) { pp[i] = self->progress_acc[i]; self->progress_acc[i] = 0; }
953 0 0 if (fire_progress_cb(self, pp) < 0) return -2;
963 0 0 for (i = 0; i < 6; i++) {
965 0 0 if (rc == 0) return 0;
966 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; }
978 0 0 for (i = 0; i < 2; i++) {
980 0 0 if (rc == 0) return 0;
981 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed table_columns packet"); return -1; }
988 0 0 if (self->on_log) {
993 0 0 if (rc <= 0) return rc;
1000 0 0 if (rc <= 0) return rc;
1009 0 0 if (rc == 0) return 0;
1010 0 0 if (rc < 0) { *errmsg = safe_strdup("malformed timezone_update packet"); return -1; }
1011 0 0 CLEAR_STR(self->server_timezone);
1042 0 0 while (self->recv_len > 0 && self->magic == EV_CH_MAGIC) {
0 0 while (self->recv_len > 0 && self->magic == EV_CH_MAGIC) {
1047 0 0 if (rc == 0) {
1052 0 0 if (rc == -2) {
1057 0 0 if (rc == 4) {
1059 0 0 if (self->native_state == NATIVE_WAIT_HELLO) {
1061 0 0 if (self->server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM) {
1066 0 0 if (try_write(self)) return;
1067 0 0 if (self->send_pos < self->send_len) {
1076 0 0 if (finish_connect(self)) return;
1083 0 0 if (rc == -1) {
1085 0 0 if (self->native_state == NATIVE_WAIT_HELLO) {
1098 0 0 CLEAR_SV(self->native_rows);
1099 0 0 CLEAR_INSERT(self);
0 0 CLEAR_INSERT(self);
1100 0 0 CLEAR_STR(self->insert_err);
1103 0 0 if (self->send_count > 0) self->send_count--;
1107 0 0 if (destroyed) return;
1114 0 0 if (rc == 2) {
1118 0 0 if (self->send_count > 0) self->send_count--;
1125 0 0 if (self->on_progress && self->progress_period > 0) {
0 0 if (self->on_progress && self->progress_period > 0) {
1127 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; }
1128 0 0 if (any) {
1132 0 0 if (fire_progress_cb(self, pp) < 0) return;
1136 0 0 if (self->insert_err) {
1139 0 0 CLEAR_SV(self->native_rows);
1142 0 0 if (destroyed) return;
1146 0 0 if (deliver_rows(self, rows)) return;
1154 0 0 if (rc == 3) {
1157 0 0 if (self->ka_in_flight > 0) {
1163 0 0 if (self->send_count > 0) self->send_count--;
1165 0 0 if (deliver_rows(self, rows)) return;