| line |
true |
false |
branch |
|
253
|
0 |
0 |
if (cbt_freelist) { |
|
279
|
0 |
0 |
if (send_freelist) { |
|
301
|
0 |
0 |
if (s->query_id) { Safefree(s->query_id); s->query_id = NULL; } |
|
309
|
0 |
0 |
if (!self->reading && self->fd >= 0) { |
|
|
0 |
0 |
if (!self->reading && self->fd >= 0) { |
|
316
|
0 |
0 |
if (self->reading) { |
|
323
|
0 |
0 |
if (!self->writing && self->fd >= 0) { |
|
|
0 |
0 |
if (!self->writing && self->fd >= 0) { |
|
330
|
0 |
0 |
if (self->writing) { |
|
337
|
0 |
0 |
if (self->magic == EV_CH_FREED && self->callback_depth == 0) { |
|
|
0 |
0 |
if (self->magic == EV_CH_FREED && self->callback_depth == 0) { |
|
345
|
0 |
0 |
if (NULL == self->on_error) return; |
|
356
|
0 |
0 |
PUSHMARK(SP); |
|
357
|
0 |
0 |
XPUSHs(sv_2mortal(newSVpv(msg, 0))); |
|
361
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
362
|
0 |
0 |
warn("EV::ClickHouse: exception in error handler: %s", SvPV_nolen(ERRSV)); |
|
365
|
0 |
0 |
FREETMPS; |
|
376
|
0 |
0 |
if (check_destroyed(self)) return 1; |
|
377
|
0 |
0 |
if (cancel_pending(self, msg)) return 1; |
|
391
|
0 |
0 |
PUSHMARK(SP); |
|
394
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
395
|
0 |
0 |
warn("EV::ClickHouse: exception in %s handler: %s", |
|
397
|
0 |
0 |
FREETMPS; |
|
407
|
0 |
0 |
if (NULL == self->on_trace) return; |
|
424
|
0 |
0 |
PUSHMARK(SP); |
|
425
|
0 |
0 |
XPUSHs(sv_2mortal(newSVpv(buf, 0))); |
|
428
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
429
|
0 |
0 |
warn("EV::ClickHouse: exception in trace handler: %s", SvPV_nolen(ERRSV)); |
|
430
|
0 |
0 |
FREETMPS; |
|
441
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) return NULL; |
|
447
|
0 |
0 |
if (cbt->on_data) { SvREFCNT_dec(cbt->on_data); cbt->on_data = NULL; } |
|
459
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) return NULL; |
|
468
|
0 |
0 |
if (ngx_queue_empty(&self->cb_queue)) return 0; |
|
476
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) { |
|
477
|
0 |
0 |
warn("EV::ClickHouse: exception in callback: %s", SvPV_nolen(ERRSV)); |
|
485
|
0 |
0 |
if (cb == NULL) return 0; |
|
492
|
0 |
0 |
PUSHMARK(SP); |
|
497
|
0 |
0 |
FREETMPS; |
|
507
|
0 |
0 |
if (cb == NULL) { |
|
508
|
0 |
0 |
if (rows) SvREFCNT_dec((SV*)rows); |
|
517
|
0 |
0 |
PUSHMARK(SP); |
|
518
|
0 |
0 |
if (rows) { |
|
525
|
0 |
0 |
FREETMPS; |
|
535
|
0 |
0 |
if (cb == NULL) return 0; |
|
542
|
0 |
0 |
PUSHMARK(SP); |
|
546
|
0 |
0 |
FREETMPS; |
|
558
|
0 |
0 |
cbt->on_data = on_data ? SvREFCNT_inc(on_data) : NULL; |
|
565
|
0 |
0 |
if (has_arg) { |
|
566
|
0 |
0 |
if (NULL != *slot) { |
|
570
|
0 |
0 |
if (NULL != handler && SvOK(handler) && |
|
|
0 |
0 |
if (NULL != handler && SvOK(handler) && |
|
571
|
0 |
0 |
SvROK(handler) && SvTYPE(SvRV(handler)) == SVt_PVCV) { |
|
|
0 |
0 |
SvROK(handler) && SvTYPE(SvRV(handler)) == SVt_PVCV) { |
|
575
|
0 |
0 |
return (NULL != *slot) ? SvREFCNT_inc(*slot) : &PL_sv_undef; |
|
581
|
0 |
0 |
if (!s) return NULL; |
|
591
|
0 |
0 |
if (!s) return 0; |
|
592
|
0 |
0 |
for (; *s; s++) |
|
593
|
0 |
0 |
if (*s == '\r' || *s == '\n') return 1; |
|
|
0 |
0 |
if (*s == '\r' || *s == '\n') return 1; |
|
603
|
0 |
0 |
if (n < self->recv_len) |
|
630
|
0 |
0 |
if (was_connected) emit_trace(self, "disconnect"); |
|
634
|
0 |
0 |
if (self->timing) { |
|
640
|
0 |
0 |
if (self->ssl) { |
|
645
|
0 |
0 |
if (self->ssl_ctx) { |
|
651
|
0 |
0 |
if (self->fd >= 0) { |
|
664
|
0 |
0 |
CLEAR_SV(self->native_rows); |
|
665
|
0 |
0 |
CLEAR_SV(self->native_col_names); |
|
666
|
0 |
0 |
CLEAR_SV(self->native_col_types); |
|
667
|
0 |
0 |
CLEAR_SV(self->native_totals); |
|
668
|
0 |
0 |
CLEAR_SV(self->native_extremes); |
|
670
|
0 |
0 |
CLEAR_STR(self->insert_data); |
|
672
|
0 |
0 |
CLEAR_SV(self->insert_av); |
|
673
|
0 |
0 |
CLEAR_STR(self->insert_err); |
|
677
|
0 |
0 |
if (was_connected && NULL != self->on_disconnect) |
|
|
0 |
0 |
if (was_connected && NULL != self->on_disconnect) |
|
685
|
0 |
0 |
while (!ngx_queue_empty(&self->send_queue)) { |
|
691
|
0 |
0 |
if (send->insert_data) Safefree(send->insert_data); |
|
692
|
0 |
0 |
if (send->insert_av) { SvREFCNT_dec(send->insert_av); send->insert_av = NULL; } |
|
693
|
0 |
0 |
if (send->on_data) { SvREFCNT_dec(send->on_data); send->on_data = NULL; } |
|
701
|
0 |
0 |
PUSHMARK(SP); |
|
706
|
0 |
0 |
FREETMPS; |
|
709
|
0 |
0 |
if (self->magic != EV_CH_MAGIC) break; |
|
712
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
714
|
0 |
0 |
if (cb == NULL) break; |
|
720
|
0 |
0 |
PUSHMARK(SP); |
|
725
|
0 |
0 |
FREETMPS; |
|
728
|
0 |
0 |
if (self->magic != EV_CH_MAGIC) break; |
|
740
|
0 |
0 |
if (self->ssl) { |
|
741
|
0 |
0 |
int ssl_len = (len > (size_t)INT_MAX) ? INT_MAX : (int)len; |
|
743
|
0 |
0 |
if (ret <= 0) { |
|
745
|
0 |
0 |
if (err == SSL_ERROR_WANT_READ) { |
|
749
|
0 |
0 |
if (err == SSL_ERROR_WANT_WRITE) { |
|
754
|
0 |
0 |
if (err == SSL_ERROR_ZERO_RETURN) return 0; |
|
766
|
0 |
0 |
if (self->ssl) { |
|
767
|
0 |
0 |
int ssl_len = (len > (size_t)INT_MAX) ? INT_MAX : (int)len; |
|
769
|
0 |
0 |
if (ret <= 0) { |
|
771
|
0 |
0 |
if (err == SSL_ERROR_WANT_WRITE) { |
|
775
|
0 |
0 |
if (err == SSL_ERROR_WANT_READ) { |
|
792
|
0 |
0 |
if (self->recv_cap >= need) return; |
|
793
|
0 |
0 |
if (need > SIZE_MAX / 2) croak("recv buffer overflow"); |
|
795
|
0 |
0 |
if (newcap < need) newcap = need; |
|
801
|
0 |
0 |
if (self->send_cap >= need) return; |
|
802
|
0 |
0 |
if (need > SIZE_MAX / 2) croak("send buffer overflow"); |
|
804
|
0 |
0 |
if (newcap < need) newcap = need; |
|
824
|
0 |
0 |
if (b->len + need > b->cap) { |
|
825
|
0 |
0 |
while (b->len + need > b->cap) { |
|
826
|
0 |
0 |
if (b->cap > SIZE_MAX / 2) croak("native buffer overflow"); |
|
841
|
0 |
0 |
while (n >= 0x80) { |
|
854
|
0 |
0 |
nbuf_string(b, s, s ? strlen(s) : 0); |
|
869
|
0 |
0 |
while (p < len) { |
|
872
|
0 |
0 |
if (!(byte & 0x80)) { |
|
878
|
0 |
0 |
if (shift >= 64) return -1; |
|
888
|
0 |
0 |
if (rc <= 0) { *pos = saved; return rc; } |
|
889
|
0 |
0 |
if (slen > len - *pos) { *pos = saved; return 0; } |
|
893
|
0 |
0 |
if (out_len) *out_len = (size_t)slen; |
|
904
|
0 |
0 |
if (rc <= 0) { *pos = saved; return rc; } |
|
905
|
0 |
0 |
if (slen > len - *pos) { *pos = saved; return 0; } |
|
913
|
0 |
0 |
if (*pos + 1 > len) return 0; |
|
920
|
0 |
0 |
if (*pos + 4 > len) return 0; |
|
937
|
0 |
0 |
if (rc <= 0) { *pos = saved; return rc; } |
|
938
|
0 |
0 |
if (slen > len - *pos) { *pos = saved; return 0; } |
|
949
|
0 |
0 |
for (i = 0; i < src_len; i++) { |
|
951
|
0 |
0 |
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || |
|
|
0 |
0 |
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || |
|
|
0 |
0 |
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || |
|
|
0 |
0 |
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || |
|
|
0 |
0 |
if ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || |
|
952
|
0 |
0 |
(c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~') { |
|
|
0 |
0 |
(c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~') { |
|
|
0 |
0 |
(c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~') { |
|
|
0 |
0 |
(c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~') { |
|
|
0 |
0 |
(c >= '0' && c <= '9') || c == '-' || c == '_' || c == '.' || c == '~') { |
|
968
|
0 |
0 |
return (klen == 3 && memcmp(key, "raw", 3) == 0) |
|
969
|
0 |
0 |
|| (klen == 8 && memcmp(key, "query_id", 8) == 0) |
|
|
0 |
0 |
|| (klen == 8 && memcmp(key, "query_id", 8) == 0) |
|
970
|
0 |
0 |
|| (klen == 7 && memcmp(key, "on_data", 7) == 0) |
|
|
0 |
0 |
|| (klen == 7 && memcmp(key, "on_data", 7) == 0) |
|
971
|
0 |
0 |
|| (klen == 13 && memcmp(key, "query_timeout", 13) == 0) |
|
|
0 |
0 |
|| (klen == 13 && memcmp(key, "query_timeout", 13) == 0) |
|
972
|
0 |
0 |
|| (klen == 6 && memcmp(key, "params", 6) == 0); |
|
|
0 |
0 |
|| (klen == 6 && memcmp(key, "params", 6) == 0); |
|
|
0 |
0 |
|| (klen == 6 && memcmp(key, "params", 6) == 0); |
|
978
|
0 |
0 |
if (overrides) { |
|
980
|
0 |
0 |
while ((entry = hv_iternext(overrides))) { |
|
984
|
0 |
0 |
if (is_client_only_key(key, klen)) continue; |
|
989
|
0 |
0 |
if (defaults) { |
|
991
|
0 |
0 |
while ((entry = hv_iternext(defaults))) { |
|
995
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
997
|
0 |
0 |
if (is_client_only_key(key, klen)) continue; |
|
1017
|
0 |
0 |
if (overrides) { |
|
1019
|
0 |
0 |
while ((entry = hv_iternext(overrides))) { |
|
1024
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
1029
|
0 |
0 |
if (is_client_only_key(key, klen)) continue; |
|
1037
|
0 |
0 |
if (defaults) { |
|
1039
|
0 |
0 |
while ((entry = hv_iternext(defaults))) { |
|
1044
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
1046
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
1047
|
0 |
0 |
if (!*query_id_out) { |
|
1053
|
0 |
0 |
if (is_client_only_key(key, klen)) continue; |
|
1069
|
0 |
0 |
if (query_id_out) *query_id_out = NULL; |
|
1070
|
0 |
0 |
if (query_id_len_out) *query_id_len_out = 0; |
|
1072
|
0 |
0 |
if (overrides) { |
|
1074
|
0 |
0 |
while ((entry = hv_iternext(overrides))) { |
|
1079
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
1080
|
0 |
0 |
if (query_id_out) { |
|
1086
|
0 |
0 |
if (is_client_only_key(key, klen)) continue; |
|
1088
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) continue; |
|
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) continue; |
|
1096
|
0 |
0 |
if (defaults) { |
|
1098
|
0 |
0 |
while ((entry = hv_iternext(defaults))) { |
|
1103
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
1105
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
|
0 |
0 |
if (klen == 8 && memcmp(key, "query_id", 8) == 0) { |
|
1106
|
0 |
0 |
if (query_id_out && !*query_id_out) { |
|
|
0 |
0 |
if (query_id_out && !*query_id_out) { |
|
1112
|
0 |
0 |
if (is_client_only_key(key, klen)) continue; |
|
1113
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) continue; |
|
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) continue; |
|
1132
|
0 |
0 |
if (data_len > (size_t)UINT_MAX) return NULL; |
|
1136
|
0 |
0 |
if (ret != Z_OK) return NULL; |
|
1139
|
0 |
0 |
if (out_cap > (size_t)UINT_MAX) { deflateEnd(&strm); return NULL; } |
|
1148
|
0 |
0 |
if (ret != Z_STREAM_END) { |
|
1166
|
0 |
0 |
if (data_len > (size_t)UINT_MAX) return NULL; |
|
1170
|
0 |
0 |
if (ret != Z_OK) return NULL; |
|
1173
|
0 |
0 |
if (out_cap < 4096) out_cap = 4096; |
|
1181
|
0 |
0 |
if (*out_len + 4096 > out_cap) { |
|
1183
|
0 |
0 |
if (out_cap > CH_MAX_DECOMPRESS_SIZE) { |
|
1194
|
0 |
0 |
if (ret == Z_STREAM_ERROR || ret == Z_DATA_ERROR || |
|
|
0 |
0 |
if (ret == Z_STREAM_ERROR || ret == Z_DATA_ERROR || |
|
|
0 |
0 |
if (ret == Z_STREAM_ERROR || ret == Z_DATA_ERROR || |
|
1195
|
0 |
0 |
ret == Z_MEM_ERROR || ret == Z_BUF_ERROR) { |
|
1201
|
0 |
0 |
} while (ret != Z_STREAM_END); |
|
1376
|
0 |
0 |
if (len >= 10 && s[4] == '-' && s[7] == '-') { |
|
|
0 |
0 |
if (len >= 10 && s[4] == '-' && s[7] == '-') { |
|
|
0 |
0 |
if (len >= 10 && s[4] == '-' && s[7] == '-') { |
|
1381
|
0 |
0 |
if (month <= 2) { year--; month += 9; } else { month -= 3; } |
|
1383
|
0 |
0 |
int era = (year >= 0 ? year : year - 399) / 400; |
|
1396
|
0 |
0 |
if (len >= 10 && s[4] == '-' && s[7] == '-') { |
|
|
0 |
0 |
if (len >= 10 && s[4] == '-' && s[7] == '-') { |
|
|
0 |
0 |
if (len >= 10 && s[4] == '-' && s[7] == '-') { |
|
1397
|
0 |
0 |
if (len >= 19) { |
|
1425
|
0 |
0 |
while (p < end) { |
|
1427
|
0 |
0 |
if (p + 1 == end && *p == '\n') break; |
|
|
0 |
0 |
if (p + 1 == end && *p == '\n') break; |
|
1432
|
0 |
0 |
while (p <= end) { |
|
1433
|
0 |
0 |
int is_end_of_line = (p == end || *p == '\n'); |
|
|
0 |
0 |
int is_end_of_line = (p == end || *p == '\n'); |
|
1434
|
0 |
0 |
int is_tab = (!is_end_of_line && *p == '\t'); |
|
|
0 |
0 |
int is_tab = (!is_end_of_line && *p == '\t'); |
|
1436
|
0 |
0 |
if (is_end_of_line || is_tab) { |
|
|
0 |
0 |
if (is_end_of_line || is_tab) { |
|
1441
|
0 |
0 |
if (field_len == 2 && field_start[0] == '\\' && field_start[1] == 'N') { |
|
|
0 |
0 |
if (field_len == 2 && field_start[0] == '\\' && field_start[1] == 'N') { |
|
|
0 |
0 |
if (field_len == 2 && field_start[0] == '\\' && field_start[1] == 'N') { |
|
1448
|
0 |
0 |
while (s < s_end) { |
|
1449
|
0 |
0 |
if (*s == '\\' && s + 1 < s_end) { |
|
|
0 |
0 |
if (*s == '\\' && s + 1 < s_end) { |
|
1471
|
0 |
0 |
if (is_tab) { |
|
1475
|
0 |
0 |
if (p < end) p++; /* skip \n */ |
|
1507
|
0 |
0 |
if (do_compress && sql_len > 0) { |
|
|
0 |
0 |
if (do_compress && sql_len > 0) { |
|
1510
|
0 |
0 |
if (body) { |
|
1520
|
0 |
0 |
+ (self->database ? strlen(self->database) * 3 : 0) |
|
1521
|
0 |
0 |
+ (self->session_id ? strlen(self->session_id) * 3 : 0) |
|
1526
|
0 |
0 |
if (self->database) { |
|
1537
|
0 |
0 |
if (self->session_id) { |
|
1549
|
0 |
0 |
if (query_id) { |
|
1551
|
0 |
0 |
if (need > params_cap) { |
|
1561
|
0 |
0 |
+ (self->host ? strlen(self->host) : 0) |
|
1562
|
0 |
0 |
+ (self->user ? strlen(self->user) : 0) |
|
1563
|
0 |
0 |
+ (self->password ? strlen(self->password) : 0); |
|
1574
|
0 |
0 |
if (self->user) { |
|
1578
|
0 |
0 |
if (self->password && self->password[0]) { |
|
|
0 |
0 |
if (self->password && self->password[0]) { |
|
1584
|
0 |
0 |
if (content_encoding) |
|
1587
|
0 |
0 |
if (self->compress) |
|
1594
|
0 |
0 |
if (body_len > 0) { |
|
1595
|
0 |
0 |
if (pos + body_len > req_cap) { |
|
1599
|
0 |
0 |
Copy(body ? body : sql, req + pos, body_len, char); |
|
1603
|
0 |
0 |
if (body) Safefree(body); |
|
1625
|
0 |
0 |
if (do_compress && data_len > 0) { |
|
|
0 |
0 |
if (do_compress && data_len > 0) { |
|
1628
|
0 |
0 |
if (body) { |
|
1645
|
0 |
0 |
+ (self->database ? strlen(self->database) * 3 : 0) |
|
1646
|
0 |
0 |
+ (self->session_id ? strlen(self->session_id) * 3 : 0) |
|
1652
|
0 |
0 |
if (self->database) { |
|
1663
|
0 |
0 |
if (self->session_id) { |
|
1684
|
0 |
0 |
if (query_id) { |
|
1686
|
0 |
0 |
if (need > params_cap) { |
|
1696
|
0 |
0 |
+ (self->host ? strlen(self->host) : 0) |
|
1697
|
0 |
0 |
+ (self->user ? strlen(self->user) : 0) |
|
1698
|
0 |
0 |
+ (self->password ? strlen(self->password) : 0); |
|
1706
|
0 |
0 |
if (self->user) { |
|
1710
|
0 |
0 |
if (self->password && self->password[0]) { |
|
|
0 |
0 |
if (self->password && self->password[0]) { |
|
1716
|
0 |
0 |
if (do_compress) |
|
1719
|
0 |
0 |
if (content_encoding) |
|
1725
|
0 |
0 |
if (body_len > 0) { |
|
1726
|
0 |
0 |
if (pos + body_len > req_cap) { |
|
1730
|
0 |
0 |
Copy(body ? body : data, req + pos, body_len, char); |
|
1734
|
0 |
0 |
if (body) Safefree(body); |
|
1743
|
0 |
0 |
size_t req_cap = 128 + (self->host ? strlen(self->host) : 0); |
|
1752
|
0 |
0 |
if (pos >= req_cap) pos = req_cap - 1; |
|
1762
|
0 |
0 |
if (len < 4) return 0; |
|
1763
|
0 |
0 |
for (i = 0; i <= len - 4; i++) { |
|
1764
|
0 |
0 |
if (buf[i] == '\r' && buf[i+1] == '\n' && |
|
|
0 |
0 |
if (buf[i] == '\r' && buf[i+1] == '\n' && |
|
1765
|
0 |
0 |
buf[i+2] == '\r' && buf[i+3] == '\n') { |
|
|
0 |
0 |
buf[i+2] == '\r' && buf[i+3] == '\n') { |
|
1774
|
0 |
0 |
if (len > 6 && memcmp(body, "Code: ", 6) == 0) |
|
|
0 |
0 |
if (len > 6 && memcmp(body, "Code: ", 6) == 0) |
|
1787
|
0 |
0 |
while (p < end && *p != ' ') p++; |
|
|
0 |
0 |
while (p < end && *p != ' ') p++; |
|
1788
|
0 |
0 |
if (p >= end) return 0; |
|
1792
|
0 |
0 |
if (status < 100 || status > 599) return 500; /* treat malformed as server error */ |
|
|
0 |
0 |
if (status < 100 || status > 599) return 500; /* treat malformed as server error */ |
|
1803
|
0 |
0 |
while (p < end) { |
|
1805
|
0 |
0 |
while (line_end < end && *line_end != '\r') line_end++; |
|
|
0 |
0 |
while (line_end < end && *line_end != '\r') line_end++; |
|
1807
|
0 |
0 |
if ((size_t)(line_end - p) > name_len + 1 && p[name_len] == ':') { |
|
|
0 |
0 |
if ((size_t)(line_end - p) > name_len + 1 && p[name_len] == ':') { |
|
1810
|
0 |
0 |
for (i = 0; i < name_len; i++) { |
|
1811
|
0 |
0 |
if (tolower((unsigned char)p[i]) != tolower((unsigned char)name[i])) { |
|
1816
|
0 |
0 |
if (match) { |
|
1818
|
0 |
0 |
while (val < line_end && *val == ' ') val++; |
|
|
0 |
0 |
while (val < line_end && *val == ' ') val++; |
|
1825
|
0 |
0 |
if (line_end + 2 <= end) p = line_end + 2; |
|
1846
|
0 |
0 |
if (self->recv_len == 0 || self->send_count == 0) return; |
|
|
0 |
0 |
if (self->recv_len == 0 || self->send_count == 0) return; |
|
1850
|
0 |
0 |
if (hdr_end == 0) return; /* need more data */ |
|
1857
|
0 |
0 |
if (val) { |
|
1863
|
0 |
0 |
if (val && val_len >= 7 && strncasecmp(val, "chunked", 7) == 0) { |
|
|
0 |
0 |
if (val && val_len >= 7 && strncasecmp(val, "chunked", 7) == 0) { |
|
|
0 |
0 |
if (val && val_len >= 7 && strncasecmp(val, "chunked", 7) == 0) { |
|
1869
|
0 |
0 |
if (val && val_len >= 4 && strncasecmp(val, "gzip", 4) == 0) { |
|
|
0 |
0 |
if (val && val_len >= 4 && strncasecmp(val, "gzip", 4) == 0) { |
|
|
0 |
0 |
if (val && val_len >= 4 && strncasecmp(val, "gzip", 4) == 0) { |
|
1873
|
0 |
0 |
if (chunked) { |
|
1880
|
0 |
0 |
while (cp < cp_end) { |
|
1884
|
0 |
0 |
while (nl < cp_end && *nl != '\r') nl++; |
|
|
0 |
0 |
while (nl < cp_end && *nl != '\r') nl++; |
|
1885
|
0 |
0 |
if (nl + 2 > cp_end) goto need_more; /* need more data */ |
|
1890
|
0 |
0 |
if (chunk_size == 0) { |
|
1892
|
0 |
0 |
if (cp + 2 > cp_end) goto need_more; |
|
1898
|
0 |
0 |
if ((size_t)(cp_end - cp) < 2 |
|
1899
|
0 |
0 |
|| chunk_size > (size_t)(cp_end - cp) - 2) goto need_more; |
|
1904
|
0 |
0 |
if (decoded_len + chunk_size < decoded_len |
|
1905
|
0 |
0 |
|| decoded_len + chunk_size > CH_MAX_DECOMPRESS_SIZE) { |
|
1906
|
0 |
0 |
if (decoded) Safefree(decoded); |
|
1909
|
0 |
0 |
if (destroyed) return; |
|
1910
|
0 |
0 |
if (cancel_pending(self, "connection closed")) return; |
|
1914
|
0 |
0 |
if (decoded == NULL) { |
|
1917
|
0 |
0 |
} else if (decoded_len + chunk_size > decoded_cap) { |
|
1926
|
0 |
0 |
if (!chunked_complete) goto need_more; |
|
1934
|
0 |
0 |
if (status == 200) { |
|
1938
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
1941
|
0 |
0 |
if (dec) { |
|
1945
|
0 |
0 |
if (decoded) Safefree(decoded); |
|
1949
|
0 |
0 |
if (destroyed) return; |
|
1958
|
0 |
0 |
if (is_raw) { |
|
1961
|
0 |
0 |
if (final_body != body) Safefree(final_body); |
|
1962
|
0 |
0 |
if (decoded) Safefree(decoded); |
|
1964
|
0 |
0 |
if (destroyed) return; |
|
1967
|
0 |
0 |
if (final_len > 0) |
|
1969
|
0 |
0 |
if (final_body != body) Safefree(final_body); |
|
1970
|
0 |
0 |
if (decoded) Safefree(decoded); |
|
1972
|
0 |
0 |
if (deliver_rows(self, rows)) return; |
|
1981
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
1984
|
0 |
0 |
if (dec) { |
|
1990
|
0 |
0 |
while (err_len > 0 && (err_body[err_len-1] == '\n' || err_body[err_len-1] == '\r')) |
|
|
0 |
0 |
while (err_len > 0 && (err_body[err_len-1] == '\n' || err_body[err_len-1] == '\r')) |
|
|
0 |
0 |
while (err_len > 0 && (err_body[err_len-1] == '\n' || err_body[err_len-1] == '\r')) |
|
1996
|
0 |
0 |
if (err_body != body) Safefree(err_body); |
|
1997
|
0 |
0 |
if (decoded) Safefree(decoded); |
|
2004
|
0 |
0 |
if (destroyed) return; |
|
2008
|
0 |
0 |
if (self->recv_len < hdr_end + content_length) return; /* need more data */ |
|
2014
|
0 |
0 |
if (status == 200) { |
|
2018
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
2021
|
0 |
0 |
if (dec) { |
|
2028
|
0 |
0 |
if (destroyed) return; |
|
2037
|
0 |
0 |
if (is_raw) { |
|
2039
|
0 |
0 |
if (final_body != body) Safefree(final_body); |
|
2041
|
0 |
0 |
if (destroyed) return; |
|
2044
|
0 |
0 |
if (final_len > 0) |
|
2046
|
0 |
0 |
if (final_body != body) Safefree(final_body); |
|
2048
|
0 |
0 |
if (deliver_rows(self, rows)) return; |
|
2056
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
|
0 |
0 |
if (is_gzip && body_len > 0) { |
|
2059
|
0 |
0 |
if (dec) { |
|
2065
|
0 |
0 |
while (err_len > 0 && (err_body[err_len-1] == '\n' || err_body[err_len-1] == '\r')) |
|
|
0 |
0 |
while (err_len > 0 && (err_body[err_len-1] == '\n' || err_body[err_len-1] == '\r')) |
|
|
0 |
0 |
while (err_len > 0 && (err_body[err_len-1] == '\n' || err_body[err_len-1] == '\r')) |
|
2072
|
0 |
0 |
if (err_body != body) Safefree(err_body); |
|
2079
|
0 |
0 |
if (destroyed) return; |
|
2083
|
0 |
0 |
if (self->magic != EV_CH_MAGIC) return; |
|
2087
|
0 |
0 |
if (self->timing) { |
|
2096
|
0 |
0 |
if (decoded) Safefree(decoded); |
|
2111
|
0 |
0 |
nbuf_cstring(&b, self->database ? self->database : "default"); |
|
2112
|
0 |
0 |
nbuf_cstring(&b, self->user ? self->user : "default"); |
|
2113
|
0 |
0 |
nbuf_cstring(&b, self->password ? self->password : ""); |
|
2188
|
0 |
0 |
if (overrides && (svp = hv_fetch(overrides, "query_id", 8, 0))) |
|
|
0 |
0 |
if (overrides && (svp = hv_fetch(overrides, "query_id", 8, 0))) |
|
2190
|
0 |
0 |
else if (defaults && (svp = hv_fetch(defaults, "query_id", 8, 0))) |
|
|
0 |
0 |
else if (defaults && (svp = hv_fetch(defaults, "query_id", 8, 0))) |
|
2196
|
0 |
0 |
if (query_id) { |
|
2264
|
0 |
0 |
if (overrides) { |
|
2267
|
0 |
0 |
while ((pe = hv_iternext(overrides))) { |
|
2272
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) { |
|
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) { |
|
2285
|
0 |
0 |
if (defaults) { |
|
2288
|
0 |
0 |
while ((pe = hv_iternext(defaults))) { |
|
2291
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) { |
|
|
0 |
0 |
if (klen > 6 && memcmp(key, "param_", 6) == 0) { |
|
2292
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
|
0 |
0 |
if (overrides && hv_exists(overrides, key, klen)) |
|
2350
|
0 |
0 |
if (!t) return; |
|
2351
|
0 |
0 |
if (t->inner) free_col_type(t->inner); |
|
2352
|
0 |
0 |
if (t->inners) { |
|
2353
|
0 |
0 |
for (i = 0; i < t->num_inners; i++) |
|
2357
|
0 |
0 |
if (t->type_str) Safefree(t->type_str); |
|
2358
|
0 |
0 |
if (t->tz) Safefree(t->tz); |
|
2375
|
0 |
0 |
for (i = 0; i <= inner_len; i++) { |
|
2376
|
0 |
0 |
if (i < inner_len && inner[i] == '(') depth++; |
|
|
0 |
0 |
if (i < inner_len && inner[i] == '(') depth++; |
|
2377
|
0 |
0 |
else if (i < inner_len && inner[i] == ')') depth--; |
|
|
0 |
0 |
else if (i < inner_len && inner[i] == ')') depth--; |
|
2378
|
0 |
0 |
else if (i == inner_len || (inner[i] == ',' && depth == 0)) |
|
|
0 |
0 |
else if (i == inner_len || (inner[i] == ',' && depth == 0)) |
|
|
0 |
0 |
else if (i == inner_len || (inner[i] == ',' && depth == 0)) |
|
2389
|
0 |
0 |
for (i = 0; i <= inner_len; i++) { |
|
2390
|
0 |
0 |
if (i < inner_len && inner[i] == '(') depth++; |
|
|
0 |
0 |
if (i < inner_len && inner[i] == '(') depth++; |
|
2391
|
0 |
0 |
else if (i < inner_len && inner[i] == ')') depth--; |
|
|
0 |
0 |
else if (i < inner_len && inner[i] == ')') depth--; |
|
2392
|
0 |
0 |
else if (i == inner_len || (inner[i] == ',' && depth == 0)) { |
|
|
0 |
0 |
else if (i == inner_len || (inner[i] == ',' && depth == 0)) { |
|
|
0 |
0 |
else if (i == inner_len || (inner[i] == ',' && depth == 0)) { |
|
2394
|
0 |
0 |
while (s < e && inner[s] == ' ') s++; |
|
|
0 |
0 |
while (s < e && inner[s] == ' ') s++; |
|
2395
|
0 |
0 |
while (e > s && inner[e-1] == ' ') e--; |
|
|
0 |
0 |
while (e > s && inner[e-1] == ' ') e--; |
|
2399
|
0 |
0 |
for (sp = s; sp < e; sp++) { |
|
2400
|
0 |
0 |
if (inner[sp] == '(') break; /* type with parens, stop */ |
|
2401
|
0 |
0 |
if (inner[sp] == ' ') { s = sp + 1; break; } |
|
2414
|
0 |
0 |
if (len == 4 && memcmp(type, "Int8", 4) == 0) t->code = CT_INT8; |
|
|
0 |
0 |
if (len == 4 && memcmp(type, "Int8", 4) == 0) t->code = CT_INT8; |
|
2415
|
0 |
0 |
else if (len == 5 && memcmp(type, "Int16", 5) == 0) t->code = CT_INT16; |
|
|
0 |
0 |
else if (len == 5 && memcmp(type, "Int16", 5) == 0) t->code = CT_INT16; |
|
2416
|
0 |
0 |
else if (len == 5 && memcmp(type, "Int32", 5) == 0) t->code = CT_INT32; |
|
|
0 |
0 |
else if (len == 5 && memcmp(type, "Int32", 5) == 0) t->code = CT_INT32; |
|
2417
|
0 |
0 |
else if (len == 5 && memcmp(type, "Int64", 5) == 0) t->code = CT_INT64; |
|
|
0 |
0 |
else if (len == 5 && memcmp(type, "Int64", 5) == 0) t->code = CT_INT64; |
|
2418
|
0 |
0 |
else if (len == 5 && memcmp(type, "UInt8", 5) == 0) t->code = CT_UINT8; |
|
|
0 |
0 |
else if (len == 5 && memcmp(type, "UInt8", 5) == 0) t->code = CT_UINT8; |
|
2419
|
0 |
0 |
else if (len == 6 && memcmp(type, "UInt16", 6) == 0) t->code = CT_UINT16; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "UInt16", 6) == 0) t->code = CT_UINT16; |
|
2420
|
0 |
0 |
else if (len == 6 && memcmp(type, "UInt32", 6) == 0) t->code = CT_UINT32; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "UInt32", 6) == 0) t->code = CT_UINT32; |
|
2421
|
0 |
0 |
else if (len == 6 && memcmp(type, "UInt64", 6) == 0) t->code = CT_UINT64; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "UInt64", 6) == 0) t->code = CT_UINT64; |
|
2422
|
0 |
0 |
else if (len == 7 && memcmp(type, "Float32", 7) == 0) t->code = CT_FLOAT32; |
|
|
0 |
0 |
else if (len == 7 && memcmp(type, "Float32", 7) == 0) t->code = CT_FLOAT32; |
|
2423
|
0 |
0 |
else if (len == 7 && memcmp(type, "Float64", 7) == 0) t->code = CT_FLOAT64; |
|
|
0 |
0 |
else if (len == 7 && memcmp(type, "Float64", 7) == 0) t->code = CT_FLOAT64; |
|
2424
|
0 |
0 |
else if (len == 6 && memcmp(type, "String", 6) == 0) t->code = CT_STRING; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "String", 6) == 0) t->code = CT_STRING; |
|
2425
|
0 |
0 |
else if (len > 12 && memcmp(type, "FixedString(", 12) == 0) { |
|
|
0 |
0 |
else if (len > 12 && memcmp(type, "FixedString(", 12) == 0) { |
|
2429
|
0 |
0 |
else if (len > 6 && memcmp(type, "Array(", 6) == 0) { |
|
|
0 |
0 |
else if (len > 6 && memcmp(type, "Array(", 6) == 0) { |
|
2433
|
0 |
0 |
else if (len > 9 && memcmp(type, "Nullable(", 9) == 0) { |
|
|
0 |
0 |
else if (len > 9 && memcmp(type, "Nullable(", 9) == 0) { |
|
2437
|
0 |
0 |
else if (len > 15 && memcmp(type, "LowCardinality(", 15) == 0) { |
|
|
0 |
0 |
else if (len > 15 && memcmp(type, "LowCardinality(", 15) == 0) { |
|
2441
|
0 |
0 |
else if (len == 4 && memcmp(type, "Date", 4) == 0) t->code = CT_DATE; |
|
|
0 |
0 |
else if (len == 4 && memcmp(type, "Date", 4) == 0) t->code = CT_DATE; |
|
2442
|
0 |
0 |
else if (len == 6 && memcmp(type, "Date32", 6) == 0) t->code = CT_DATE32; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "Date32", 6) == 0) t->code = CT_DATE32; |
|
2443
|
0 |
0 |
else if (len == 8 && memcmp(type, "DateTime", 8) == 0) t->code = CT_DATETIME; |
|
|
0 |
0 |
else if (len == 8 && memcmp(type, "DateTime", 8) == 0) t->code = CT_DATETIME; |
|
2444
|
0 |
0 |
else if (len > 9 && memcmp(type, "DateTime(", 9) == 0) { |
|
|
0 |
0 |
else if (len > 9 && memcmp(type, "DateTime(", 9) == 0) { |
|
2449
|
0 |
0 |
if (q) { |
|
2451
|
0 |
0 |
if (qe && qe > q + 1) { |
|
|
0 |
0 |
if (qe && qe > q + 1) { |
|
2460
|
0 |
0 |
else if (len > 11 && memcmp(type, "DateTime64(", 11) == 0) { |
|
|
0 |
0 |
else if (len > 11 && memcmp(type, "DateTime64(", 11) == 0) { |
|
2466
|
0 |
0 |
if (comma) { |
|
2468
|
0 |
0 |
if (q) { |
|
2470
|
0 |
0 |
if (qe && qe > q + 1) { |
|
|
0 |
0 |
if (qe && qe > q + 1) { |
|
2480
|
0 |
0 |
else if (len == 4 && memcmp(type, "UUID", 4) == 0) t->code = CT_UUID; |
|
|
0 |
0 |
else if (len == 4 && memcmp(type, "UUID", 4) == 0) t->code = CT_UUID; |
|
2481
|
0 |
0 |
else if (len > 6 && memcmp(type, "Enum8(", 6) == 0) { |
|
|
0 |
0 |
else if (len > 6 && memcmp(type, "Enum8(", 6) == 0) { |
|
2488
|
0 |
0 |
else if (len > 7 && memcmp(type, "Enum16(", 7) == 0) { |
|
|
0 |
0 |
else if (len > 7 && memcmp(type, "Enum16(", 7) == 0) { |
|
2495
|
0 |
0 |
else if (len > 10 && memcmp(type, "Decimal32(", 10) == 0) { |
|
|
0 |
0 |
else if (len > 10 && memcmp(type, "Decimal32(", 10) == 0) { |
|
2499
|
0 |
0 |
else if (len > 10 && memcmp(type, "Decimal64(", 10) == 0) { |
|
|
0 |
0 |
else if (len > 10 && memcmp(type, "Decimal64(", 10) == 0) { |
|
2503
|
0 |
0 |
else if (len > 11 && memcmp(type, "Decimal128(", 11) == 0) { |
|
|
0 |
0 |
else if (len > 11 && memcmp(type, "Decimal128(", 11) == 0) { |
|
2507
|
0 |
0 |
else if (len > 8 && memcmp(type, "Decimal(", 8) == 0) { |
|
|
0 |
0 |
else if (len > 8 && memcmp(type, "Decimal(", 8) == 0) { |
|
2510
|
0 |
0 |
t->param = comma ? atoi(comma + 1) : 0; |
|
2511
|
0 |
0 |
if (precision <= 9) t->code = CT_DECIMAL32; |
|
2512
|
0 |
0 |
else if (precision <= 18) t->code = CT_DECIMAL64; |
|
2515
|
0 |
0 |
else if (len == 7 && memcmp(type, "Nothing", 7) == 0) t->code = CT_NOTHING; |
|
|
0 |
0 |
else if (len == 7 && memcmp(type, "Nothing", 7) == 0) t->code = CT_NOTHING; |
|
2516
|
0 |
0 |
else if (len == 4 && memcmp(type, "Bool", 4) == 0) t->code = CT_BOOL; |
|
|
0 |
0 |
else if (len == 4 && memcmp(type, "Bool", 4) == 0) t->code = CT_BOOL; |
|
2517
|
0 |
0 |
else if (len == 4 && memcmp(type, "IPv4", 4) == 0) t->code = CT_IPV4; |
|
|
0 |
0 |
else if (len == 4 && memcmp(type, "IPv4", 4) == 0) t->code = CT_IPV4; |
|
2518
|
0 |
0 |
else if (len == 4 && memcmp(type, "IPv6", 4) == 0) t->code = CT_IPV6; |
|
|
0 |
0 |
else if (len == 4 && memcmp(type, "IPv6", 4) == 0) t->code = CT_IPV6; |
|
2519
|
0 |
0 |
else if (len == 6 && memcmp(type, "Int128", 6) == 0) t->code = CT_INT128; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "Int128", 6) == 0) t->code = CT_INT128; |
|
2520
|
0 |
0 |
else if (len == 7 && memcmp(type, "UInt128", 7) == 0) t->code = CT_UINT128; |
|
|
0 |
0 |
else if (len == 7 && memcmp(type, "UInt128", 7) == 0) t->code = CT_UINT128; |
|
2521
|
0 |
0 |
else if (len == 6 && memcmp(type, "Int256", 6) == 0) t->code = CT_INT256; |
|
|
0 |
0 |
else if (len == 6 && memcmp(type, "Int256", 6) == 0) t->code = CT_INT256; |
|
2522
|
0 |
0 |
else if (len == 7 && memcmp(type, "UInt256", 7) == 0) t->code = CT_UINT256; |
|
|
0 |
0 |
else if (len == 7 && memcmp(type, "UInt256", 7) == 0) t->code = CT_UINT256; |
|
2523
|
0 |
0 |
else if (len > 6 && memcmp(type, "Tuple(", 6) == 0) { |
|
|
0 |
0 |
else if (len > 6 && memcmp(type, "Tuple(", 6) == 0) { |
|
2527
|
0 |
0 |
else if (len > 4 && memcmp(type, "Map(", 4) == 0) { |
|
|
0 |
0 |
else if (len > 4 && memcmp(type, "Map(", 4) == 0) { |
|
2531
|
0 |
0 |
else if (len > 7 && memcmp(type, "Nested(", 7) == 0) { |
|
|
0 |
0 |
else if (len > 7 && memcmp(type, "Nested(", 7) == 0) { |
|
2540
|
0 |
0 |
else if (len > 25 && memcmp(type, "SimpleAggregateFunction(", 24) == 0) { |
|
|
0 |
0 |
else if (len > 25 && memcmp(type, "SimpleAggregateFunction(", 24) == 0) { |
|
2547
|
0 |
0 |
for (ci = 0; ci < inner_len; ci++) { |
|
2548
|
0 |
0 |
if (inner[ci] == '(') depth++; |
|
2549
|
0 |
0 |
else if (inner[ci] == ')') depth--; |
|
2550
|
0 |
0 |
else if (inner[ci] == ',' && depth == 0) break; |
|
|
0 |
0 |
else if (inner[ci] == ',' && depth == 0) break; |
|
2552
|
0 |
0 |
if (ci < inner_len) { |
|
2555
|
0 |
0 |
while (ci < inner_len && inner[ci] == ' ') ci++; |
|
|
0 |
0 |
while (ci < inner_len && inner[ci] == ' ') ci++; |
|
2595
|
0 |
0 |
if (!gmtime_r(&t, &tm)) return newSVpvn("0000-00-00", 10); |
|
2606
|
0 |
0 |
if (!gmtime_r(&t, &tm)) return newSVpvn("0000-00-00 00:00:00", 19); |
|
2618
|
0 |
0 |
if (!localtime_r(&t, &tm)) return newSVpvn("0000-00-00 00:00:00", 19); |
|
2635
|
0 |
0 |
for (p = 0; p < precision; p++) scale *= 10; |
|
2638
|
0 |
0 |
if (frac < 0) { epoch--; frac += scale; } |
|
2641
|
0 |
0 |
if (use_local) { |
|
2642
|
0 |
0 |
if (!localtime_r(&t, &tm)) return newSVpvn("0000-00-00 00:00:00", 19); |
|
2644
|
0 |
0 |
if (!gmtime_r(&t, &tm)) return newSVpvn("0000-00-00 00:00:00", 19); |
|
2649
|
0 |
0 |
if (precision > 0 && n < 30) { |
|
|
0 |
0 |
if (precision > 0 && n < 30) { |
|
2654
|
0 |
0 |
for (fi = 0; fi < precision && n < 31; fi++) |
|
|
0 |
0 |
for (fi = 0; fi < precision && n < 31; fi++) |
|
2676
|
0 |
0 |
if (old_tz) { |
|
2688
|
0 |
0 |
if (saved) { |
|
2701
|
0 |
0 |
for (i = 0; i < n; i++) r *= 10.0; |
|
2710
|
0 |
0 |
if (!p) return newSViv(code); |
|
2714
|
0 |
0 |
while (p < end) { |
|
2716
|
0 |
0 |
while (p < end && *p == ' ') p++; |
|
|
0 |
0 |
while (p < end && *p == ' ') p++; |
|
2717
|
0 |
0 |
if (p >= end || *p != '\'') break; |
|
|
0 |
0 |
if (p >= end || *p != '\'') break; |
|
2726
|
0 |
0 |
while (p < end && !(*p == '\'' && (p + 1 >= end || *(p+1) != '\''))) { |
|
|
0 |
0 |
while (p < end && !(*p == '\'' && (p + 1 >= end || *(p+1) != '\''))) { |
|
|
0 |
0 |
while (p < end && !(*p == '\'' && (p + 1 >= end || *(p+1) != '\''))) { |
|
|
0 |
0 |
while (p < end && !(*p == '\'' && (p + 1 >= end || *(p+1) != '\''))) { |
|
2727
|
0 |
0 |
if (*p == '\'' && p + 1 < end && *(p+1) == '\'') { p += 2; continue; } |
|
|
0 |
0 |
if (*p == '\'' && p + 1 < end && *(p+1) == '\'') { p += 2; continue; } |
|
|
0 |
0 |
if (*p == '\'' && p + 1 < end && *(p+1) == '\'') { p += 2; continue; } |
|
2731
|
0 |
0 |
if (p < end) p++; /* skip closing quote */ |
|
2734
|
0 |
0 |
while (p < end && (*p == ' ' || *p == '=')) p++; |
|
|
0 |
0 |
while (p < end && (*p == ' ' || *p == '=')) p++; |
|
|
0 |
0 |
while (p < end && (*p == ' ' || *p == '=')) p++; |
|
2739
|
0 |
0 |
if (val == code) return newSVpvn(label_start, label_len); |
|
2742
|
0 |
0 |
while (p < end && *p != ',') p++; |
|
|
0 |
0 |
while (p < end && *p != ',') p++; |
|
2743
|
0 |
0 |
if (p < end) p++; /* skip comma */ |
|
2762
|
0 |
0 |
if (is_signed) { |
|
2766
|
0 |
0 |
uv = neg ? -(unsigned __int128)sv : (unsigned __int128)sv; |
|
2773
|
0 |
0 |
} while (uv); |
|
2774
|
0 |
0 |
if (neg) dbuf[dlen++] = '-'; |
|
2775
|
0 |
0 |
for (k = 0; k < dlen/2; k++) { |
|
2793
|
0 |
0 |
if (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0) |
|
|
0 |
0 |
if (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0) |
|
|
0 |
0 |
if (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0) |
|
|
0 |
0 |
if (v[0] == 0 && v[1] == 0 && v[2] == 0 && v[3] == 0) |
|
2797
|
0 |
0 |
while (v[0] || v[1] || v[2] || v[3]) { |
|
|
0 |
0 |
while (v[0] || v[1] || v[2] || v[3]) { |
|
|
0 |
0 |
while (v[0] || v[1] || v[2] || v[3]) { |
|
|
0 |
0 |
while (v[0] || v[1] || v[2] || v[3]) { |
|
2800
|
0 |
0 |
for (i = 3; i >= 0; i--) { |
|
2818
|
0 |
0 |
for (k = 0; k < dlen/2; k++) { |
|
2825
|
0 |
0 |
if (is_signed && ((unsigned char)p[31] & 0x80)) { |
|
|
0 |
0 |
if (is_signed && ((unsigned char)p[31] & 0x80)) { |
|
2832
|
0 |
0 |
for (i = 0; i < 32; i++) { |
|
2873
|
0 |
0 |
Newxz(out, nrows ? nrows : 1, SV*); |
|
|
0 |
0 |
Newxz(out, nrows ? nrows : 1, SV*); |
|
|
0 |
0 |
Newxz(out, nrows ? nrows : 1, SV*); |
|
2875
|
0 |
0 |
if (ct->code == CT_NOTHING) { |
|
2877
|
0 |
0 |
if (*pos > len || nrows > len - *pos) goto fail; |
|
|
0 |
0 |
if (*pos > len || nrows > len - *pos) goto fail; |
|
2879
|
0 |
0 |
for (i = 0; i < nrows; i++) |
|
2884
|
0 |
0 |
if (ct->code == CT_NULLABLE) { |
|
2888
|
0 |
0 |
if (*pos > len || nrows > len - *pos) goto fail; |
|
|
0 |
0 |
if (*pos > len || nrows > len - *pos) goto fail; |
|
2895
|
0 |
0 |
if (!inner) { Safefree(nulls); goto fail; } |
|
2897
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
2898
|
0 |
0 |
if (nulls[i]) { |
|
2910
|
0 |
0 |
if (ct->code == CT_LOWCARDINALITY) { |
|
2928
|
0 |
0 |
if (*pos + 8 > len) goto fail; |
|
2932
|
0 |
0 |
if (*pos + 8 > len) { *pos = saved; goto fail; } |
|
2939
|
0 |
0 |
if (ser_type & (1ULL << 10)) { |
|
2940
|
0 |
0 |
if (*pos + 8 > len) { *pos = saved; goto fail; } |
|
2944
|
0 |
0 |
if (!dict) { *pos = saved; goto fail; } |
|
2947
|
0 |
0 |
if (lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols |
|
|
0 |
0 |
if (lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols |
|
|
0 |
0 |
if (lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols |
|
2948
|
0 |
0 |
&& lc_self->lc_dicts[lc_col_idx]) { |
|
2953
|
0 |
0 |
if (decode_err) *decode_err = 1; |
|
2960
|
0 |
0 |
if (*pos + 8 > len) { |
|
2961
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
2966
|
0 |
0 |
idx_size = (key_type == 0) ? 1 : (key_type == 1) ? 2 : |
|
|
0 |
0 |
idx_size = (key_type == 0) ? 1 : (key_type == 1) ? 2 : |
|
|
0 |
0 |
idx_size = (key_type == 0) ? 1 : (key_type == 1) ? 2 : |
|
2968
|
0 |
0 |
if (num_indices != nrows) { |
|
2969
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
2970
|
0 |
0 |
*pos = saved; if (decode_err) *decode_err = 1; goto fail; |
|
2972
|
0 |
0 |
if (*pos > len || num_indices > (len - *pos) / idx_size) { |
|
|
0 |
0 |
if (*pos > len || num_indices > (len - *pos) / idx_size) { |
|
2973
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
|
0 |
0 |
if (dict && !dict_borrowed) { for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); Safefree(dict); } |
|
2978
|
0 |
0 |
if (!dict_borrowed && lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols) { |
|
|
0 |
0 |
if (!dict_borrowed && lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols) { |
|
|
0 |
0 |
if (!dict_borrowed && lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols) { |
|
|
0 |
0 |
if (!dict_borrowed && lc_self && lc_col_idx >= 0 && lc_col_idx < lc_self->lc_num_cols) { |
|
2979
|
0 |
0 |
if (lc_self->lc_dicts[lc_col_idx]) { |
|
2981
|
0 |
0 |
for (di = 0; di < lc_self->lc_dict_sizes[lc_col_idx]; di++) |
|
2986
|
0 |
0 |
Newx(dcopy, num_keys > 0 ? num_keys : 1, SV*); |
|
|
0 |
0 |
Newx(dcopy, num_keys > 0 ? num_keys : 1, SV*); |
|
|
0 |
0 |
Newx(dcopy, num_keys > 0 ? num_keys : 1, SV*); |
|
2987
|
0 |
0 |
for (i = 0; i < num_keys; i++) |
|
2993
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
2996
|
0 |
0 |
if (dict && idx < num_keys) { |
|
|
0 |
0 |
if (dict && idx < num_keys) { |
|
3004
|
0 |
0 |
if (dict && !dict_borrowed) { |
|
|
0 |
0 |
if (dict && !dict_borrowed) { |
|
3005
|
0 |
0 |
for (i = 0; i < num_keys; i++) SvREFCNT_dec(dict[i]); |
|
3011
|
0 |
0 |
if (ct->code == CT_STRING) { |
|
3012
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3015
|
0 |
0 |
if (read_native_string_ref(buf, len, pos, &s, &slen) <= 0) { |
|
3018
|
0 |
0 |
for (j = 0; j < i; j++) SvREFCNT_dec(out[j]); |
|
3026
|
0 |
0 |
if (ct->code == CT_ARRAY) { |
|
3032
|
0 |
0 |
if (*pos > len || nrows > (len - *pos) / 8) goto fail; |
|
|
0 |
0 |
if (*pos > len || nrows > (len - *pos) / 8) goto fail; |
|
3033
|
0 |
0 |
Newx(offsets, nrows, uint64_t); |
|
3034
|
0 |
0 |
Copy(buf + *pos, offsets, nrows, uint64_t); |
|
3039
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3040
|
0 |
0 |
if (offsets[i] < prev) { Safefree(offsets); goto fail; } |
|
3044
|
0 |
0 |
total = nrows > 0 ? offsets[nrows - 1] : 0; |
|
3048
|
0 |
0 |
if (!elems) { Safefree(offsets); goto fail; } |
|
3052
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3056
|
0 |
0 |
if (count > 0) av_extend(av, count - 1); |
|
3057
|
0 |
0 |
for (j = 0; j < count; j++) { |
|
3069
|
0 |
0 |
if (ct->code == CT_TUPLE) { |
|
3075
|
0 |
0 |
for (j = 0; j < ct->num_inners; j++) { |
|
3077
|
0 |
0 |
if (!cols[j]) { |
|
3079
|
0 |
0 |
for (k = 0; k < j; k++) { |
|
3080
|
0 |
0 |
for (i = 0; i < nrows; i++) SvREFCNT_dec(cols[k][i]); |
|
3088
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3091
|
0 |
0 |
for (j = 0; j < ct->num_inners; j++) |
|
3096
|
0 |
0 |
for (j = 0; j < ct->num_inners; j++) Safefree(cols[j]); |
|
3101
|
0 |
0 |
if (ct->code == CT_MAP) { |
|
3102
|
0 |
0 |
if (ct->num_inners != 2) { if (decode_err) *decode_err = 1; goto fail; } |
|
|
0 |
0 |
if (ct->num_inners != 2) { if (decode_err) *decode_err = 1; goto fail; } |
|
3107
|
0 |
0 |
if (*pos > len || nrows > (len - *pos) / 8) goto fail; |
|
|
0 |
0 |
if (*pos > len || nrows > (len - *pos) / 8) goto fail; |
|
3108
|
0 |
0 |
Newx(offsets, nrows, uint64_t); |
|
3109
|
0 |
0 |
Copy(buf + *pos, offsets, nrows, uint64_t); |
|
3114
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3115
|
0 |
0 |
if (offsets[i] < prev) { Safefree(offsets); goto fail; } |
|
3119
|
0 |
0 |
total = nrows > 0 ? offsets[nrows - 1] : 0; |
|
3122
|
0 |
0 |
if (!keys_col) { Safefree(offsets); goto fail; } |
|
3125
|
0 |
0 |
if (!vals_col) { |
|
3126
|
0 |
0 |
for (i = 0; i < total; i++) SvREFCNT_dec(keys_col[i]); |
|
3133
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3137
|
0 |
0 |
for (j = 0; j < count; j++) { |
|
3142
|
0 |
0 |
if (!hv_store(hv, kstr, klen, val_sv, 0)) |
|
3150
|
0 |
0 |
for (i = 0; i < total; i++) { |
|
3162
|
0 |
0 |
if (ct->code == CT_FIXEDSTRING && fsz == 0) { |
|
|
0 |
0 |
if (ct->code == CT_FIXEDSTRING && fsz == 0) { |
|
3164
|
0 |
0 |
for (i = 0; i < nrows; i++) |
|
3168
|
0 |
0 |
if (fsz > 0) { |
|
3172
|
0 |
0 |
if (*pos > len || nrows > (len - *pos) / fsz) goto fail; |
|
|
0 |
0 |
if (*pos > len || nrows > (len - *pos) / fsz) goto fail; |
|
3175
|
0 |
0 |
if (ct->tz && (decode_flags & DECODE_DT_STR) && |
|
|
0 |
0 |
if (ct->tz && (decode_flags & DECODE_DT_STR) && |
|
3176
|
0 |
0 |
(ct->code == CT_DATETIME || ct->code == CT_DATETIME64)) { |
|
|
0 |
0 |
(ct->code == CT_DATETIME || ct->code == CT_DATETIME64)) { |
|
3181
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3196
|
0 |
0 |
if (decode_flags & DECODE_ENUM_STR) |
|
3203
|
0 |
0 |
if (decode_flags & DECODE_ENUM_STR) |
|
3211
|
0 |
0 |
if (decode_flags & DECODE_DT_STR) |
|
3219
|
0 |
0 |
if (decode_flags & DECODE_DT_STR) |
|
3227
|
0 |
0 |
if (decode_flags & DECODE_DT_STR) |
|
3229
|
0 |
0 |
: epoch_to_datetime_sv(v); |
|
3236
|
0 |
0 |
if (decode_flags & DECODE_DT_STR) |
|
3244
|
0 |
0 |
if (decode_flags & DECODE_DEC_SCALE) |
|
3252
|
0 |
0 |
if (decode_flags & DECODE_DEC_SCALE) |
|
3260
|
0 |
0 |
if (decode_flags & DECODE_DEC_SCALE) { |
|
3326
|
0 |
0 |
if (tz_set) restore_tz(saved_tz); |
|
3332
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3335
|
0 |
0 |
if (read_native_string_ref(buf, len, pos, &s, &slen) <= 0) { |
|
3337
|
0 |
0 |
for (j = 0; j < i; j++) SvREFCNT_dec(out[j]); |
|
3354
|
0 |
0 |
for (i = 0; i < src_len; i++) { |
|
3355
|
0 |
0 |
if (src[i] == '\\' && i + 1 < src_len) { |
|
|
0 |
0 |
if (src[i] == '\\' && i + 1 < src_len) { |
|
3376
|
0 |
0 |
return len == 2 && s[0] == '\\' && s[1] == 'N'; |
|
|
0 |
0 |
return len == 2 && s[0] == '\\' && s[1] == 'N'; |
|
|
0 |
0 |
return len == 2 && s[0] == '\\' && s[1] == 'N'; |
|
3382
|
0 |
0 |
for (i = 0; i < len; i++) { |
|
3394
|
0 |
0 |
if (esc) { |
|
3395
|
0 |
0 |
if (i > start) |
|
3403
|
0 |
0 |
if (start < len) |
|
3416
|
0 |
0 |
for (r = 0; r < nrows; r++) { |
|
3421
|
0 |
0 |
if (!row_svp || !SvROK(*row_svp) || |
|
|
0 |
0 |
if (!row_svp || !SvROK(*row_svp) || |
|
3422
|
0 |
0 |
SvTYPE(SvRV(*row_svp)) != SVt_PVAV) { |
|
3429
|
0 |
0 |
for (c = 0; c < ncols; c++) { |
|
3431
|
0 |
0 |
if (c > 0) |
|
3434
|
0 |
0 |
if (!val_svp || !SvOK(*val_svp)) { |
|
|
0 |
0 |
if (!val_svp || !SvOK(*val_svp)) { |
|
3436
|
0 |
0 |
} else if (SvROK(*val_svp)) { |
|
3469
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3476
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3483
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3485
|
0 |
0 |
if (ct->code == CT_DATE32 && value_lens[i] >= 10 |
|
|
0 |
0 |
if (ct->code == CT_DATE32 && value_lens[i] >= 10 |
|
3486
|
0 |
0 |
&& values[i][4] == '-') |
|
3495
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3502
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3509
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3511
|
0 |
0 |
if (ct->code == CT_DATE && value_lens[i] >= 10 |
|
|
0 |
0 |
if (ct->code == CT_DATE && value_lens[i] >= 10 |
|
3512
|
0 |
0 |
&& values[i][4] == '-') |
|
3521
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3523
|
0 |
0 |
if (ct->code == CT_DATETIME && value_lens[i] >= 10 |
|
|
0 |
0 |
if (ct->code == CT_DATETIME && value_lens[i] >= 10 |
|
3524
|
0 |
0 |
&& values[i][4] == '-') |
|
3533
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3540
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3547
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3554
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3556
|
0 |
0 |
if (value_lens[i] >= 10 && values[i][4] == '-') { |
|
|
0 |
0 |
if (value_lens[i] >= 10 && values[i][4] == '-') { |
|
3560
|
0 |
0 |
for (s = 0; s < ct->param; s++) v *= 10; |
|
3562
|
0 |
0 |
if (value_lens[i] >= 20 && values[i][19] == '.') { |
|
|
0 |
0 |
if (value_lens[i] >= 20 && values[i][19] == '.') { |
|
3567
|
0 |
0 |
while (fp < fe && digits < prec) { |
|
|
0 |
0 |
while (fp < fe && digits < prec) { |
|
3572
|
0 |
0 |
while (digits < prec) { frac *= 10; digits++; } |
|
3583
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3588
|
0 |
0 |
if (*p == '-') { neg = 1; p++; } |
|
3589
|
0 |
0 |
else if (*p == '+') p++; |
|
3590
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
3591
|
0 |
0 |
if (*p == '.') { |
|
3593
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
3599
|
0 |
0 |
for (s = frac_digits; s < scale; s++) frac_part *= 10; |
|
3600
|
0 |
0 |
for (s = 0; s < scale; s++) integer_part *= 10; |
|
3603
|
0 |
0 |
if (neg) raw = -raw; |
|
3611
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3616
|
0 |
0 |
if (*p == '-') { neg = 1; p++; } |
|
3617
|
0 |
0 |
else if (*p == '+') p++; |
|
3618
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
3619
|
0 |
0 |
if (*p == '.') { |
|
3621
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
3627
|
0 |
0 |
for (s = frac_digits; s < scale; s++) frac_part *= 10; |
|
3628
|
0 |
0 |
for (s = 0; s < scale; s++) integer_part *= 10; |
|
3631
|
0 |
0 |
if (neg) v = -v; |
|
3638
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3639
|
0 |
0 |
if (memchr(values[i], '\\', value_lens[i])) { |
|
3654
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3655
|
0 |
0 |
if (memchr(values[i], '\\', value_lens[i])) { |
|
3669
|
0 |
0 |
if (cplen < fsz) |
|
3679
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3683
|
0 |
0 |
if (slen >= 36) { |
|
3687
|
0 |
0 |
for (j = 0; j < (int)slen && k < 32; j++) { |
|
|
0 |
0 |
for (j = 0; j < (int)slen && k < 32; j++) { |
|
3689
|
0 |
0 |
if (c == '-') continue; |
|
3692
|
0 |
0 |
if (c >= '0' && c <= '9') nibble = c - '0'; |
|
|
0 |
0 |
if (c >= '0' && c <= '9') nibble = c - '0'; |
|
3693
|
0 |
0 |
else if (c >= 'a' && c <= 'f') nibble = 10 + c - 'a'; |
|
|
0 |
0 |
else if (c >= 'a' && c <= 'f') nibble = 10 + c - 'a'; |
|
3694
|
0 |
0 |
else if (c >= 'A' && c <= 'F') nibble = 10 + c - 'A'; |
|
|
0 |
0 |
else if (c >= 'A' && c <= 'F') nibble = 10 + c - 'A'; |
|
3696
|
0 |
0 |
if (k % 2 == 0) raw[k/2] = nibble << 4; |
|
3702
|
0 |
0 |
for (k = 0; k < 8; k++) ubytes[k] = raw[7 - k]; |
|
3703
|
0 |
0 |
for (k = 0; k < 8; k++) ubytes[8 + k] = raw[15 - k]; |
|
3712
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3719
|
0 |
0 |
if (inet_pton(AF_INET, tmp, &addr) == 1) |
|
3726
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3747
|
0 |
0 |
Newxz(inner_vals, nrows, const char *); |
|
3748
|
0 |
0 |
Newx(inner_lens, nrows, size_t); |
|
3750
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3751
|
0 |
0 |
if (is_tsv_null(values[i], value_lens[i])) { |
|
3754
|
0 |
0 |
if (ct->inner->code == CT_STRING || ct->inner->code == CT_FIXEDSTRING) { |
|
|
0 |
0 |
if (ct->inner->code == CT_STRING || ct->inner->code == CT_FIXEDSTRING) { |
|
3786
|
0 |
0 |
if (nrows <= 0xFF) { key_type = 0; idx_size = 1; } |
|
3787
|
0 |
0 |
else if (nrows <= 0xFFFF) { key_type = 1; idx_size = 2; } |
|
3805
|
0 |
0 |
if (!rc) { Safefree(dict_buf.data); return 0; } |
|
3814
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3815
|
0 |
0 |
if (idx_size == 1) { |
|
3818
|
0 |
0 |
} else if (idx_size == 2) { |
|
3845
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3846
|
0 |
0 |
int8_t v = SvIOK(values[i]) ? (int8_t)SvIV(values[i]) |
|
3853
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3854
|
0 |
0 |
int16_t v = SvIOK(values[i]) ? (int16_t)SvIV(values[i]) |
|
3861
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3863
|
0 |
0 |
if (SvIOK(values[i])) { |
|
3868
|
0 |
0 |
if (ct->code == CT_DATE32 && vlen >= 10 && s[4] == '-') |
|
|
0 |
0 |
if (ct->code == CT_DATE32 && vlen >= 10 && s[4] == '-') |
|
|
0 |
0 |
if (ct->code == CT_DATE32 && vlen >= 10 && s[4] == '-') |
|
3878
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3880
|
0 |
0 |
: (int64_t)strtoll(SvPV_nolen(values[i]), NULL, 10); |
|
3886
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3887
|
0 |
0 |
uint8_t v = SvIOK(values[i]) ? (uint8_t)SvUV(values[i]) |
|
3894
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3896
|
0 |
0 |
if (SvIOK(values[i])) { |
|
3901
|
0 |
0 |
if (ct->code == CT_DATE && vlen >= 10 && s[4] == '-') |
|
|
0 |
0 |
if (ct->code == CT_DATE && vlen >= 10 && s[4] == '-') |
|
|
0 |
0 |
if (ct->code == CT_DATE && vlen >= 10 && s[4] == '-') |
|
3911
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3913
|
0 |
0 |
if (SvIOK(values[i])) { |
|
3918
|
0 |
0 |
if (ct->code == CT_DATETIME && vlen >= 10 && s[4] == '-') |
|
|
0 |
0 |
if (ct->code == CT_DATETIME && vlen >= 10 && s[4] == '-') |
|
|
0 |
0 |
if (ct->code == CT_DATETIME && vlen >= 10 && s[4] == '-') |
|
3928
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3930
|
0 |
0 |
: (uint64_t)strtoull(SvPV_nolen(values[i]), NULL, 10); |
|
3936
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3938
|
0 |
0 |
: strtof(SvPV_nolen(values[i]), NULL); |
|
3944
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3946
|
0 |
0 |
: strtod(SvPV_nolen(values[i]), NULL); |
|
3952
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3954
|
0 |
0 |
if (SvIOK(values[i])) { |
|
3959
|
0 |
0 |
if (vlen >= 10 && s[4] == '-') { |
|
|
0 |
0 |
if (vlen >= 10 && s[4] == '-') { |
|
3963
|
0 |
0 |
for (sc = 0; sc < ct->param; sc++) v *= 10; |
|
3964
|
0 |
0 |
if (vlen >= 20 && s[19] == '.') { |
|
|
0 |
0 |
if (vlen >= 20 && s[19] == '.') { |
|
3969
|
0 |
0 |
while (fp < fe && digits < prec) { |
|
|
0 |
0 |
while (fp < fe && digits < prec) { |
|
3974
|
0 |
0 |
while (digits < prec) { frac *= 10; digits++; } |
|
3986
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
3992
|
0 |
0 |
if (*p == '-') { neg = 1; p++; } |
|
3993
|
0 |
0 |
else if (*p == '+') p++; |
|
3994
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
3995
|
0 |
0 |
if (*p == '.') { |
|
3997
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
4001
|
0 |
0 |
for (s = frac_digits; s < scale; s++) frac_part *= 10; |
|
4002
|
0 |
0 |
for (s = 0; s < scale; s++) integer_part *= 10; |
|
4005
|
0 |
0 |
if (neg) raw = -raw; |
|
4013
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4019
|
0 |
0 |
if (*p == '-') { neg = 1; p++; } |
|
4020
|
0 |
0 |
else if (*p == '+') p++; |
|
4021
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9') { integer_part = integer_part * 10 + (*p - '0'); p++; } |
|
4022
|
0 |
0 |
if (*p == '.') { |
|
4024
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
|
0 |
0 |
while (*p >= '0' && *p <= '9' && frac_digits < scale) { |
|
4028
|
0 |
0 |
for (s = frac_digits; s < scale; s++) frac_part *= 10; |
|
4029
|
0 |
0 |
for (s = 0; s < scale; s++) integer_part *= 10; |
|
4032
|
0 |
0 |
if (neg) v = -v; |
|
4039
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4048
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4054
|
0 |
0 |
if (cplen < fsz) |
|
4061
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4065
|
0 |
0 |
if (slen >= 36) { |
|
4068
|
0 |
0 |
for (j = 0; j < (int)slen && k < 32; j++) { |
|
|
0 |
0 |
for (j = 0; j < (int)slen && k < 32; j++) { |
|
4070
|
0 |
0 |
if (c == '-') continue; |
|
4073
|
0 |
0 |
if (c >= '0' && c <= '9') nibble = c - '0'; |
|
|
0 |
0 |
if (c >= '0' && c <= '9') nibble = c - '0'; |
|
4074
|
0 |
0 |
else if (c >= 'a' && c <= 'f') nibble = 10 + c - 'a'; |
|
|
0 |
0 |
else if (c >= 'a' && c <= 'f') nibble = 10 + c - 'a'; |
|
4075
|
0 |
0 |
else if (c >= 'A' && c <= 'F') nibble = 10 + c - 'A'; |
|
|
0 |
0 |
else if (c >= 'A' && c <= 'F') nibble = 10 + c - 'A'; |
|
4077
|
0 |
0 |
if (k % 2 == 0) raw[k/2] = nibble << 4; |
|
4082
|
0 |
0 |
for (k = 0; k < 8; k++) ubytes[k] = raw[7 - k]; |
|
4083
|
0 |
0 |
for (k = 0; k < 8; k++) ubytes[8 + k] = raw[15 - k]; |
|
4092
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4101
|
0 |
0 |
if (inet_pton(AF_INET, tmp, &addr) == 1) |
|
4108
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4128
|
0 |
0 |
Newx(inner_vals, nrows ? nrows : 1, SV *); |
|
|
0 |
0 |
Newx(inner_vals, nrows ? nrows : 1, SV *); |
|
|
0 |
0 |
Newx(inner_vals, nrows ? nrows : 1, SV *); |
|
4131
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4132
|
0 |
0 |
if (!SvOK(values[i])) { |
|
4157
|
0 |
0 |
if (nrows <= 0xFF) { key_type = 0; idx_size = 1; } |
|
4158
|
0 |
0 |
else if (nrows <= 0xFFFF) { key_type = 1; idx_size = 2; } |
|
4171
|
0 |
0 |
if (!rc) { Safefree(dict_buf.data); return 0; } |
|
4178
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4179
|
0 |
0 |
if (idx_size == 1) { |
|
4182
|
0 |
0 |
} else if (idx_size == 2) { |
|
4200
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4202
|
0 |
0 |
if (!SvROK(values[i]) || SvTYPE(SvRV(values[i])) != SVt_PVAV) |
|
|
0 |
0 |
if (!SvROK(values[i]) || SvTYPE(SvRV(values[i])) != SVt_PVAV) |
|
4205
|
0 |
0 |
{ SSize_t cnt = av_len(av) + 1; if (cnt > 0) total += (uint64_t)cnt; } |
|
4208
|
0 |
0 |
Newx(offsets, nrows, uint64_t); |
|
4209
|
0 |
0 |
Newx(all_elems, total ? total : 1, SV *); |
|
|
0 |
0 |
Newx(all_elems, total ? total : 1, SV *); |
|
|
0 |
0 |
Newx(all_elems, total ? total : 1, SV *); |
|
4211
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4214
|
0 |
0 |
for (j = 0; j < n; j++) { |
|
4216
|
0 |
0 |
all_elems[pos++] = ep ? *ep : &PL_sv_undef; |
|
4231
|
0 |
0 |
for (j = 0; j < ct->num_inners; j++) { |
|
4234
|
0 |
0 |
Newx(col_vals, nrows ? nrows : 1, SV *); |
|
|
0 |
0 |
Newx(col_vals, nrows ? nrows : 1, SV *); |
|
|
0 |
0 |
Newx(col_vals, nrows ? nrows : 1, SV *); |
|
4235
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4238
|
0 |
0 |
if (!SvROK(values[i]) || SvTYPE(SvRV(values[i])) != SVt_PVAV) { |
|
|
0 |
0 |
if (!SvROK(values[i]) || SvTYPE(SvRV(values[i])) != SVt_PVAV) { |
|
4244
|
0 |
0 |
col_vals[i] = ep ? *ep : &PL_sv_undef; |
|
4248
|
0 |
0 |
if (!rc) return 0; |
|
4260
|
0 |
0 |
if (ct->num_inners != 2) return 0; |
|
4262
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4264
|
0 |
0 |
if (!SvROK(values[i]) || SvTYPE(SvRV(values[i])) != SVt_PVHV) |
|
|
0 |
0 |
if (!SvROK(values[i]) || SvTYPE(SvRV(values[i])) != SVt_PVHV) |
|
4267
|
0 |
0 |
total += HvUSEDKEYS(hv); |
|
4270
|
0 |
0 |
Newx(offsets, nrows, uint64_t); |
|
4271
|
0 |
0 |
Newx(all_keys, total ? total : 1, SV *); |
|
|
0 |
0 |
Newx(all_keys, total ? total : 1, SV *); |
|
|
0 |
0 |
Newx(all_keys, total ? total : 1, SV *); |
|
4272
|
0 |
0 |
Newx(all_vals, total ? total : 1, SV *); |
|
|
0 |
0 |
Newx(all_vals, total ? total : 1, SV *); |
|
|
0 |
0 |
Newx(all_vals, total ? total : 1, SV *); |
|
4274
|
0 |
0 |
for (i = 0; i < nrows; i++) { |
|
4278
|
0 |
0 |
while ((he = hv_iternext(hv))) { |
|
4288
|
0 |
0 |
if (rc) rc = encode_column_sv(aTHX_ b, all_vals, total, ct->inners[1]); |
|
4361
|
0 |
0 |
while (p < end) { |
|
4363
|
0 |
0 |
const char *line_limit = line_end ? line_end : end; |
|
4367
|
0 |
0 |
if (p == line_limit) { p = line_limit + 1; continue; } |
|
4369
|
0 |
0 |
if (nrows >= max_rows) { |
|
4370
|
0 |
0 |
if (max_rows > INT_MAX / 2 || |
|
|
0 |
0 |
if (max_rows > INT_MAX / 2 || |
|
4371
|
0 |
0 |
(num_cols > 0 && max_rows * 2 > INT_MAX / num_cols)) { |
|
4385
|
0 |
0 |
for (col = 0; col < num_cols; col++) { |
|
4387
|
0 |
0 |
if (fp > line_limit) fp = line_limit; |
|
4388
|
0 |
0 |
if (col < num_cols - 1) { |
|
4390
|
0 |
0 |
if (!tab) tab = line_limit; |
|
4403
|
0 |
0 |
if (nrows == 0) { |
|
4430
|
0 |
0 |
for (col = 0; col < num_cols; col++) { |
|
4443
|
0 |
0 |
for (row = 0; row < nrows; row++) { |
|
4448
|
0 |
0 |
if (!encode_column_text(&body, col_vals, col_vlens, |
|
4467
|
0 |
0 |
if (!result) { *out_len = 0; return NULL; } |
|
4488
|
0 |
0 |
if (nrows <= 0) { |
|
4508
|
0 |
0 |
for (col = 0; col < num_cols; col++) { |
|
4517
|
0 |
0 |
Newx(col_vals, nrows, SV *); |
|
4518
|
0 |
0 |
for (row = 0; row < nrows; row++) { |
|
4523
|
0 |
0 |
if (!row_svp || !SvROK(*row_svp) || SvTYPE(SvRV(*row_svp)) != SVt_PVAV) { |
|
|
0 |
0 |
if (!row_svp || !SvROK(*row_svp) || SvTYPE(SvRV(*row_svp)) != SVt_PVAV) { |
|
|
0 |
0 |
if (!row_svp || !SvROK(*row_svp) || SvTYPE(SvRV(*row_svp)) != SVt_PVAV) { |
|
4531
|
0 |
0 |
col_vals[row] = (val_svp && *val_svp) ? *val_svp : &PL_sv_undef; |
|
|
0 |
0 |
col_vals[row] = (val_svp && *val_svp) ? *val_svp : &PL_sv_undef; |
|
4534
|
0 |
0 |
if (!encode_column_sv(aTHX_ &body, col_vals, (uint64_t)nrows, col_types[col])) { |
|
4545
|
0 |
0 |
if (!result) { *out_len = 0; return NULL; } |
|
4560
|
0 |
0 |
if (rc == 0) return 0; |
|
4561
|
0 |
0 |
if (rc < 0) return -1; |
|
4562
|
0 |
0 |
if (field_num == 0) return 1; /* end marker */ |
|
4563
|
0 |
0 |
if (field_num == 1) { |
|
4567
|
0 |
0 |
if (rc <= 0) return rc; |
|
4568
|
0 |
0 |
} else if (field_num == 2) { |
|
4572
|
0 |
0 |
if (rc <= 0) return rc; |
|
4614
|
0 |
0 |
if (rc == 0) return 0; |
|
4615
|
0 |
0 |
if (rc < 0) { |
|
4656
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
4661
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
4663
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
4665
|
0 |
0 |
for (c = 0; c < nc; c++) { |
|
4669
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
4671
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
|
0 |
0 |
if (rc <= 0) _BAIL(rc); |
|
4673
|
0 |
0 |
if (bpos >= blen) _BAIL(0); |
|
|
0 |
0 |
if (bpos >= blen) _BAIL(0); |
|
4674
|
0 |
0 |
if ((uint8_t)bbuf[bpos]) { |
|
4675
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4680
|
0 |
0 |
if (nr > 0) { |
|
4684
|
0 |
0 |
if (!vals) { |
|
4686
|
0 |
0 |
if (col_err || decompressed) { |
|
|
0 |
0 |
if (col_err || decompressed) { |
|
4687
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4696
|
0 |
0 |
for (j = 0; j < nr; j++) SvREFCNT_dec(vals[j]); |
|
4706
|
0 |
0 |
if (!decompressed) pos = bpos; |
|
4707
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4720
|
0 |
0 |
if (rc == 0) return 0; |
|
4721
|
0 |
0 |
if (rc < 0) { |
|
4734
|
0 |
0 |
if (rc == 0) return 0; |
|
4735
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed server name"); return -1; } |
|
4738
|
0 |
0 |
if (rc == 0) { Safefree(sname); return 0; } |
|
4739
|
0 |
0 |
if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server version major"); return -1; } |
|
4742
|
0 |
0 |
if (rc == 0) { Safefree(sname); return 0; } |
|
4743
|
0 |
0 |
if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server version minor"); return -1; } |
|
4746
|
0 |
0 |
if (rc == 0) { Safefree(sname); return 0; } |
|
4747
|
0 |
0 |
if (rc < 0) { Safefree(sname); *errmsg = safe_strdup("malformed server revision"); return -1; } |
|
4749
|
0 |
0 |
if (self->server_name) Safefree(self->server_name); |
|
4759
|
0 |
0 |
if (rc == 0) return 0; |
|
4760
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed timezone"); return -1; } |
|
4761
|
0 |
0 |
if (self->server_timezone) Safefree(self->server_timezone); |
|
4769
|
0 |
0 |
if (rc == 0) return 0; |
|
4770
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed display name"); return -1; } |
|
4771
|
0 |
0 |
if (self->server_display_name) Safefree(self->server_display_name); |
|
4779
|
0 |
0 |
if (rc == 0) return 0; |
|
4780
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed version patch"); return -1; } |
|
4799
|
0 |
0 |
if (rc == 0) return 0; |
|
4800
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed table name"); return -1; } |
|
4827
|
0 |
0 |
if (rc == 0) { |
|
4828
|
0 |
0 |
if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; } |
|
4831
|
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; } |
|
4835
|
0 |
0 |
if (rc == 0) { |
|
4836
|
0 |
0 |
if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; } |
|
4839
|
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; } |
|
4842
|
0 |
0 |
if (rc == 0) { |
|
4843
|
0 |
0 |
if (decompressed) { Safefree(decompressed); *errmsg = safe_strdup("truncated compressed block"); return -1; } |
|
4846
|
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; } |
|
4849
|
0 |
0 |
if (num_rows == 0) { |
|
4851
|
0 |
0 |
if (self->native_state == NATIVE_WAIT_INSERT_META |
|
4852
|
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) { |
|
4862
|
0 |
0 |
Newxz(cnames, num_cols, const char *); |
|
4863
|
0 |
0 |
Newxz(cname_lens, num_cols, size_t); |
|
4864
|
0 |
0 |
Newxz(ctypes_str, num_cols, const char *); |
|
4865
|
0 |
0 |
Newxz(ctype_lens, num_cols, size_t); |
|
4866
|
0 |
0 |
Newxz(ctypes, num_cols, col_type_t *); |
|
4868
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
4872
|
0 |
0 |
if (rc <= 0) { |
|
4874
|
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]); |
|
4878
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4879
|
0 |
0 |
if (rc < 0 || was_compressed) { *errmsg = safe_strdup("malformed cname"); return -1; } |
|
|
0 |
0 |
if (rc < 0 || was_compressed) { *errmsg = safe_strdup("malformed cname"); return -1; } |
|
4884
|
0 |
0 |
if (rc <= 0) { |
|
4886
|
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]); |
|
4890
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4891
|
0 |
0 |
if (rc < 0 || was_compressed) { *errmsg = safe_strdup("malformed ctype"); return -1; } |
|
|
0 |
0 |
if (rc < 0 || was_compressed) { *errmsg = safe_strdup("malformed ctype"); return -1; } |
|
4897
|
0 |
0 |
if (dpos >= dlen) { |
|
4899
|
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]); |
|
4903
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4904
|
0 |
0 |
if (was_compressed) { *errmsg = safe_strdup("truncated custom_ser"); return -1; } |
|
4907
|
0 |
0 |
if ((uint8_t)dbuf[dpos]) { |
|
4908
|
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]); |
|
4912
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4920
|
0 |
0 |
if (self->insert_av) { |
|
4932
|
0 |
0 |
for (c = 0; c < num_cols; c++) |
|
4940
|
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); |
|
4943
|
0 |
0 |
if (self->insert_data) { |
|
4948
|
0 |
0 |
if (self->insert_av) { |
|
4953
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
4957
|
0 |
0 |
if (!data_pkt) { |
|
4964
|
0 |
0 |
if (encode_failed) |
|
4973
|
0 |
0 |
if (try_write(self)) return -2; |
|
4979
|
0 |
0 |
if (self->native_state == NATIVE_WAIT_INSERT_META |
|
4980
|
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) { |
|
4983
|
0 |
0 |
if (self->insert_data) { |
|
4988
|
0 |
0 |
if (self->insert_av) { |
|
4993
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5003
|
0 |
0 |
if (try_write(self)) return -2; |
|
5010
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5011
|
0 |
0 |
if (skip_native_string(dbuf, dlen, &dpos) <= 0) { |
|
5012
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5015
|
0 |
0 |
if (skip_native_string(dbuf, dlen, &dpos) <= 0) { |
|
5016
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5020
|
0 |
0 |
if (dpos >= dlen) { |
|
5021
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5024
|
0 |
0 |
if ((uint8_t)dbuf[dpos]) { |
|
5025
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5032
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5047
|
0 |
0 |
Newxz(columns, num_cols, SV**); |
|
5048
|
0 |
0 |
Newxz(col_types, num_cols, col_type_t*); |
|
5049
|
0 |
0 |
if (named) { |
|
5050
|
0 |
0 |
Newxz(cnames, num_cols, const char *); |
|
5051
|
0 |
0 |
Newx(cname_lens, num_cols, size_t); |
|
5054
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5062
|
0 |
0 |
if (rc == 0) { |
|
5063
|
0 |
0 |
if (decompressed) { *errmsg = safe_strdup("truncated cname"); goto data_error; } |
|
5066
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed cname"); goto data_error; } |
|
5068
|
0 |
0 |
if (named) { |
|
5074
|
0 |
0 |
if (c == 0 && !self->native_rows && self->native_col_names) { |
|
|
0 |
0 |
if (c == 0 && !self->native_rows && self->native_col_names) { |
|
|
0 |
0 |
if (c == 0 && !self->native_rows && self->native_col_names) { |
|
5077
|
0 |
0 |
if (self->native_col_types) { |
|
5082
|
0 |
0 |
if (!self->native_col_names) { |
|
5083
|
0 |
0 |
if (c == 0) { |
|
5088
|
0 |
0 |
if (self->native_col_names && av_len(self->native_col_names) + 1 < (SSize_t)num_cols) |
|
|
0 |
0 |
if (self->native_col_names && av_len(self->native_col_names) + 1 < (SSize_t)num_cols) |
|
5092
|
0 |
0 |
if (rc == 0) { |
|
5093
|
0 |
0 |
if (decompressed) { *errmsg = safe_strdup("truncated ctype"); goto data_error; } |
|
5096
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed ctype"); goto data_error; } |
|
5099
|
0 |
0 |
if (self->native_col_types && av_len(self->native_col_types) + 1 < (SSize_t)num_cols) |
|
|
0 |
0 |
if (self->native_col_types && av_len(self->native_col_types) + 1 < (SSize_t)num_cols) |
|
5103
|
0 |
0 |
if (dpos >= dlen) { |
|
5104
|
0 |
0 |
if (decompressed) { *errmsg = safe_strdup("truncated custom_ser"); goto data_error; } |
|
5107
|
0 |
0 |
if ((uint8_t)dbuf[dpos]) { |
|
5114
|
0 |
0 |
if (c == 0 && !self->lc_dicts && num_cols > 0) { |
|
|
0 |
0 |
if (c == 0 && !self->lc_dicts && num_cols > 0) { |
|
|
0 |
0 |
if (c == 0 && !self->lc_dicts && num_cols > 0) { |
|
5115
|
0 |
0 |
Newxz(self->lc_dicts, num_cols, SV**); |
|
5116
|
0 |
0 |
Newxz(self->lc_dict_sizes, num_cols, uint64_t); |
|
5123
|
0 |
0 |
if (!columns[c]) { |
|
5124
|
0 |
0 |
if (col_err || decompressed) { |
|
|
0 |
0 |
if (col_err || decompressed) { |
|
5136
|
0 |
0 |
if (ptype == SERVER_TOTALS) { |
|
5137
|
0 |
0 |
if (!self->native_totals) self->native_totals = newAV(); |
|
5139
|
0 |
0 |
} else if (ptype == SERVER_EXTREMES) { |
|
5140
|
0 |
0 |
if (!self->native_extremes) self->native_extremes = newAV(); |
|
5143
|
0 |
0 |
if (!self->native_rows) self->native_rows = newAV(); |
|
5147
|
0 |
0 |
if (named) { |
|
5148
|
0 |
0 |
for (r = 0; r < num_rows; r++) { |
|
5150
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5151
|
0 |
0 |
if (!hv_store(hv, cnames[c], cname_lens[c], columns[c][r], 0)) |
|
5157
|
0 |
0 |
for (r = 0; r < num_rows; r++) { |
|
5159
|
0 |
0 |
if (num_cols > 0) |
|
5161
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5171
|
0 |
0 |
SV *on_data = (ptype == SERVER_DATA) ? peek_cb_on_data(self) : NULL; |
|
5172
|
0 |
0 |
if (on_data && self->native_rows) { |
|
|
0 |
0 |
if (on_data && self->native_rows) { |
|
5177
|
0 |
0 |
PUSHMARK(SP); |
|
5181
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
5182
|
0 |
0 |
warn("EV::ClickHouse: exception in on_data handler: %s", |
|
5184
|
0 |
0 |
FREETMPS; LEAVE; |
|
5190
|
0 |
0 |
if (check_destroyed(self)) { |
|
5191
|
0 |
0 |
if (cnames) Safefree(cnames); |
|
5192
|
0 |
0 |
if (cname_lens) Safefree(cname_lens); |
|
5193
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5198
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5205
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5211
|
0 |
0 |
if (cnames) Safefree(cnames); |
|
5212
|
0 |
0 |
if (cname_lens) Safefree(cname_lens); |
|
5213
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5223
|
0 |
0 |
for (c = 0; c < num_cols; c++) { |
|
5224
|
0 |
0 |
if (columns[c]) { |
|
5226
|
0 |
0 |
for (j = 0; j < num_rows; j++) { |
|
5227
|
0 |
0 |
if (columns[c][j]) SvREFCNT_dec(columns[c][j]); |
|
5231
|
0 |
0 |
if (col_types[c]) free_col_type(col_types[c]); |
|
5235
|
0 |
0 |
if (cnames) Safefree(cnames); |
|
5236
|
0 |
0 |
if (cname_lens) Safefree(cname_lens); |
|
5237
|
0 |
0 |
if (decompressed) Safefree(decompressed); |
|
5238
|
0 |
0 |
if (*errmsg) { |
|
5258
|
0 |
0 |
if (rc == 0) return 0; |
|
5259
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed exception code"); return -1; } |
|
5262
|
0 |
0 |
if (rc == 0) return 0; |
|
5263
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed exception name"); return -1; } |
|
5266
|
0 |
0 |
if (rc == 0) return 0; |
|
5267
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed exception message"); return -1; } |
|
5270
|
0 |
0 |
if (rc == 0) return 0; |
|
5271
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed exception stack"); return -1; } |
|
5274
|
0 |
0 |
if (rc == 0) return 0; |
|
5275
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed exception has_nested"); return -1; } |
|
5278
|
0 |
0 |
while (has_nested) { |
|
5281
|
0 |
0 |
if (rc == 0) return 0; |
|
5282
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; } |
|
5285
|
0 |
0 |
if (rc == 0) return 0; |
|
5286
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; } |
|
5289
|
0 |
0 |
if (rc == 0) return 0; |
|
5290
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; } |
|
5293
|
0 |
0 |
if (rc == 0) return 0; |
|
5294
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; } |
|
5297
|
0 |
0 |
if (rc == 0) return 0; |
|
5298
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed nested exception"); return -1; } |
|
5319
|
0 |
0 |
if (rc == 0) return 0; |
|
5320
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; } |
|
5323
|
0 |
0 |
if (rc == 0) return 0; |
|
5324
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; } |
|
5327
|
0 |
0 |
if (rc == 0) return 0; |
|
5328
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; } |
|
5332
|
0 |
0 |
if (rc == 0) return 0; |
|
5333
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; } |
|
5336
|
0 |
0 |
if (rc == 0) return 0; |
|
5337
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed progress packet"); return -1; } |
|
5342
|
0 |
0 |
if (NULL != self->on_progress) { |
|
5346
|
0 |
0 |
PUSHMARK(SP); |
|
5347
|
0 |
0 |
EXTEND(SP, 5); |
|
5355
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
|
0 |
0 |
if (SvTRUE(ERRSV)) |
|
5356
|
0 |
0 |
warn("EV::ClickHouse: exception in progress handler: %s", |
|
5358
|
0 |
0 |
FREETMPS; LEAVE; |
|
5360
|
0 |
0 |
if (check_destroyed(self)) return -2; /* destroyed */ |
|
5371
|
0 |
0 |
if (rc == 0) return 0; |
|
5372
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; } |
|
5374
|
0 |
0 |
if (rc == 0) return 0; |
|
5375
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; } |
|
5377
|
0 |
0 |
if (rc == 0) return 0; |
|
5378
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; } |
|
5380
|
0 |
0 |
if (rc == 0) return 0; |
|
5381
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; } |
|
5383
|
0 |
0 |
if (rc == 0) return 0; |
|
5384
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; } |
|
5386
|
0 |
0 |
if (rc == 0) return 0; |
|
5387
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed profile_info packet"); return -1; } |
|
5399
|
0 |
0 |
if (rc == 0) return 0; |
|
5400
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed table_columns packet"); return -1; } |
|
5402
|
0 |
0 |
if (rc == 0) return 0; |
|
5403
|
0 |
0 |
if (rc < 0) { *errmsg = safe_strdup("malformed table_columns packet"); return -1; } |
|
5410
|
0 |
0 |
if (rc <= 0) return rc; |
|
5417
|
0 |
0 |
if (rc <= 0) return rc; |
|
5448
|
0 |
0 |
while (self->recv_len > 0 && self->magic == EV_CH_MAGIC) { |
|
|
0 |
0 |
while (self->recv_len > 0 && self->magic == EV_CH_MAGIC) { |
|
5453
|
0 |
0 |
if (rc == 0) { |
|
5458
|
0 |
0 |
if (rc == -2) { |
|
5463
|
0 |
0 |
if (rc == 4) { |
|
5465
|
0 |
0 |
if (self->native_state == NATIVE_WAIT_HELLO) { |
|
5467
|
0 |
0 |
if (self->server_revision >= DBMS_MIN_PROTOCOL_VERSION_WITH_ADDENDUM) { |
|
5472
|
0 |
0 |
if (try_write(self)) return; |
|
5481
|
0 |
0 |
if (!ngx_queue_empty(&self->send_queue)) |
|
5489
|
0 |
0 |
if (rc == -1) { |
|
5491
|
0 |
0 |
if (self->native_state == NATIVE_WAIT_HELLO) { |
|
5495
|
0 |
0 |
if (check_destroyed(self)) return; |
|
5496
|
0 |
0 |
if (cancel_pending(self, "connection failed")) return; |
|
5502
|
0 |
0 |
if (self->timing) { |
|
5508
|
0 |
0 |
if (self->native_rows) { |
|
5512
|
0 |
0 |
if (self->insert_data) { |
|
5517
|
0 |
0 |
if (self->insert_av) { |
|
5521
|
0 |
0 |
if (self->insert_err) { |
|
5527
|
0 |
0 |
if (self->send_count > 0) self->send_count--; |
|
5531
|
0 |
0 |
if (destroyed) return; |
|
5538
|
0 |
0 |
if (rc == 2) { |
|
5540
|
0 |
0 |
if (self->timing) { |
|
5545
|
0 |
0 |
if (self->send_count > 0) self->send_count--; |
|
5548
|
0 |
0 |
if (self->insert_err) { |
|
5551
|
0 |
0 |
if (self->native_rows) { |
|
5557
|
0 |
0 |
if (destroyed) return; |
|
5561
|
0 |
0 |
if (deliver_rows(self, rows)) return; |
|
5569
|
0 |
0 |
if (rc == 3) { |
|
5572
|
0 |
0 |
if (self->ka_in_flight > 0) { |
|
5577
|
0 |
0 |
if (self->timing) { |
|
5581
|
0 |
0 |
if (self->send_count > 0) self->send_count--; |
|
5583
|
0 |
0 |
if (deliver_rows(self, rows)) return; |
|
5601
|
0 |
0 |
self->protocol == PROTO_NATIVE ? "native" : "http"); |
|
5609
|
0 |
0 |
if (ret != 0) { |
|
5617
|
0 |
0 |
if (fd < 0) { |
|
5626
|
0 |
0 |
if (fl < 0 || fcntl(fd, F_SETFL, fl | O_NONBLOCK) < 0) { |
|
|
0 |
0 |
if (fl < 0 || fcntl(fd, F_SETFL, fl | O_NONBLOCK) < 0) { |
|
5646
|
0 |
0 |
if (ret == 0) { |
|
5650
|
0 |
0 |
if (self->protocol != PROTO_NATIVE && !self->tls_enabled) |
|
|
0 |
0 |
if (self->protocol != PROTO_NATIVE && !self->tls_enabled) |
|
5660
|
0 |
0 |
if (errno != EINPROGRESS) { |
|
5678
|
0 |
0 |
if (self->connect_timeout > 0) { |
|
5690
|
0 |
0 |
if (self->timing) { |
|
5696
|
0 |
0 |
if (self->tls_enabled) { |
|
5699
|
0 |
0 |
if (!self->ssl_ctx) { |
|
5704
|
0 |
0 |
if (self->tls_skip_verify) |
|
5708
|
0 |
0 |
if (self->tls_ca_file) { |
|
5709
|
0 |
0 |
if (SSL_CTX_load_verify_locations(self->ssl_ctx, self->tls_ca_file, NULL) != 1) { |
|
5715
|
0 |
0 |
if (!self->ssl) { |
|
5724
|
0 |
0 |
if (!host_is_ip) |
|
5728
|
0 |
0 |
if (!self->tls_skip_verify) { |
|
5731
|
0 |
0 |
if (host_is_ip) |
|
5738
|
0 |
0 |
if (ret == 1) { |
|
5743
|
0 |
0 |
if (err == SSL_ERROR_WANT_READ) { |
|
5745
|
0 |
0 |
} else if (err == SSL_ERROR_WANT_WRITE) { |
|
5758
|
0 |
0 |
if (self->protocol == PROTO_NATIVE) { |
|
5776
|
0 |
0 |
if (!ngx_queue_empty(&self->send_queue)) |
|
5784
|
0 |
0 |
while (self->send_pos < self->send_len) { |
|
5787
|
0 |
0 |
if (n < 0) { |
|
5788
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) { |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) { |
|
5794
|
0 |
0 |
if (check_destroyed(self)) return 1; |
|
5795
|
0 |
0 |
if (cancel_pending(self, "write error")) return 1; |
|
5799
|
0 |
0 |
if (n == 0) { |
|
5801
|
0 |
0 |
if (check_destroyed(self)) return 1; |
|
5802
|
0 |
0 |
if (cancel_pending(self, "connection closed")) return 1; |
|
5818
|
0 |
0 |
if (!ngx_queue_empty(&self->send_queue)) |
|
5830
|
0 |
0 |
if (n < 0) { |
|
5831
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) return; |
|
|
0 |
0 |
if (errno == EAGAIN || errno == EWOULDBLOCK) return; |
|
5833
|
0 |
0 |
if (check_destroyed(self)) return; |
|
5834
|
0 |
0 |
if (cancel_pending(self, "read error")) return; |
|
5839
|
0 |
0 |
if (n == 0) { |
|
5842
|
0 |
0 |
int had_inflight = (self->send_count > 0 || !self->connected); |
|
|
0 |
0 |
int had_inflight = (self->send_count > 0 || !self->connected); |
|
5845
|
0 |
0 |
if (had_inflight) { |
|
5847
|
0 |
0 |
if (check_destroyed(self)) return; |
|
5850
|
0 |
0 |
if (!self->auto_reconnect || !has_queued) { |
|
|
0 |
0 |
if (!self->auto_reconnect || !has_queued) { |
|
5851
|
0 |
0 |
if (cancel_pending(self, "connection closed")) return; |
|
5854
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
5856
|
0 |
0 |
if (cb == NULL) break; |
|
5861
|
0 |
0 |
PUSHMARK(SP); |
|
5866
|
0 |
0 |
FREETMPS; LEAVE; |
|
5869
|
0 |
0 |
if (check_destroyed(self)) return; |
|
5877
|
0 |
0 |
if (self->auto_reconnect && self->host && self->magic == EV_CH_MAGIC) { |
|
|
0 |
0 |
if (self->auto_reconnect && self->host && self->magic == EV_CH_MAGIC) { |
|
|
0 |
0 |
if (self->auto_reconnect && self->host && self->magic == EV_CH_MAGIC) { |
|
5885
|
0 |
0 |
if (self->protocol == PROTO_HTTP) { |
|
5896
|
0 |
0 |
if (self == NULL || self->magic != EV_CH_MAGIC) return; |
|
|
0 |
0 |
if (self == NULL || self->magic != EV_CH_MAGIC) return; |
|
5898
|
0 |
0 |
if (self->connecting) { |
|
5903
|
0 |
0 |
if (self->timing) { |
|
5909
|
0 |
0 |
if (getsockopt(self->fd, SOL_SOCKET, SO_ERROR, &err, &errlen) < 0) |
|
5911
|
0 |
0 |
if (err != 0) { |
|
5923
|
0 |
0 |
if (self->ssl && !self->connected && self->native_state != NATIVE_WAIT_HELLO |
|
|
0 |
0 |
if (self->ssl && !self->connected && self->native_state != NATIVE_WAIT_HELLO |
|
|
0 |
0 |
if (self->ssl && !self->connected && self->native_state != NATIVE_WAIT_HELLO |
|
5924
|
0 |
0 |
&& self->native_state != NATIVE_WAIT_RESULT |
|
5925
|
0 |
0 |
&& self->native_state != NATIVE_WAIT_INSERT_META) { |
|
5928
|
0 |
0 |
if (ret == 1) { |
|
5932
|
0 |
0 |
if (self->protocol == PROTO_NATIVE) { |
|
5946
|
0 |
0 |
if (!ngx_queue_empty(&self->send_queue)) |
|
5953
|
0 |
0 |
if (err == SSL_ERROR_WANT_READ) { |
|
5955
|
0 |
0 |
} else if (err == SSL_ERROR_WANT_WRITE) { |
|
5965
|
0 |
0 |
if (revents & EV_WRITE) { |
|
5966
|
0 |
0 |
if (try_write(self)) return; |
|
5967
|
0 |
0 |
if (self->fd < 0) return; |
|
5970
|
0 |
0 |
if (revents & EV_READ) { |
|
5980
|
0 |
0 |
if (self == NULL || self->magic != EV_CH_MAGIC) return; |
|
|
0 |
0 |
if (self == NULL || self->magic != EV_CH_MAGIC) return; |
|
5984
|
0 |
0 |
if (self->connecting) { |
|
5989
|
0 |
0 |
if (self->native_rows) { |
|
5993
|
0 |
0 |
if (self->native_col_names) { |
|
5997
|
0 |
0 |
if (self->native_col_types) { |
|
6002
|
0 |
0 |
if (self->insert_data) { |
|
6007
|
0 |
0 |
if (self->insert_av) { |
|
6011
|
0 |
0 |
if (self->insert_err) { |
|
6016
|
0 |
0 |
if (self->send_count > 0) self->send_count--; |
|
6018
|
0 |
0 |
if (deliver_error(self, "query timeout")) return; |
|
6021
|
0 |
0 |
if (cancel_pending(self, "query timeout")) return; |
|
6023
|
0 |
0 |
if (self->auto_reconnect && self->host) |
|
|
0 |
0 |
if (self->auto_reconnect && self->host) |
|
6035
|
0 |
0 |
if (self->magic != EV_CH_MAGIC) return; |
|
6036
|
0 |
0 |
if (!self->connected || self->send_count > 0) return; |
|
|
0 |
0 |
if (!self->connected || self->send_count > 0) return; |
|
6039
|
0 |
0 |
if (self->protocol == PROTO_NATIVE) { |
|
6048
|
0 |
0 |
if (!self->writing) start_writing(self); |
|
6055
|
0 |
0 |
if (self->keepalive > 0 && !self->ka_timing && self->connected) { |
|
|
0 |
0 |
if (self->keepalive > 0 && !self->ka_timing && self->connected) { |
|
|
0 |
0 |
if (self->keepalive > 0 && !self->ka_timing && self->connected) { |
|
6063
|
0 |
0 |
if (self->ka_timing) { |
|
6076
|
0 |
0 |
if (self->magic != EV_CH_MAGIC || self->connected || self->connecting) return; |
|
|
0 |
0 |
if (self->magic != EV_CH_MAGIC || self->connected || self->connecting) return; |
|
|
0 |
0 |
if (self->magic != EV_CH_MAGIC || self->connected || self->connecting) return; |
|
6081
|
0 |
0 |
if (!self->auto_reconnect || !self->host || self->magic != EV_CH_MAGIC) return; |
|
|
0 |
0 |
if (!self->auto_reconnect || !self->host || self->magic != EV_CH_MAGIC) return; |
|
|
0 |
0 |
if (!self->auto_reconnect || !self->host || self->magic != EV_CH_MAGIC) return; |
|
6082
|
0 |
0 |
if (self->reconnect_delay <= 0) { |
|
6089
|
0 |
0 |
for (i = 0; i < self->reconnect_attempts && i < 20; i++) |
|
|
0 |
0 |
for (i = 0; i < self->reconnect_attempts && i < 20; i++) |
|
6091
|
0 |
0 |
if (self->reconnect_max_delay > 0 && delay > self->reconnect_max_delay) |
|
|
0 |
0 |
if (self->reconnect_max_delay > 0 && delay > self->reconnect_max_delay) |
|
6094
|
0 |
0 |
if (self->reconnect_timing) { |
|
6105
|
0 |
0 |
if (self->lc_dicts) { |
|
6107
|
0 |
0 |
for (c = 0; c < self->lc_num_cols; c++) { |
|
6108
|
0 |
0 |
if (self->lc_dicts[c]) { |
|
6110
|
0 |
0 |
for (j = 0; j < self->lc_dict_sizes[c]; j++) |
|
6131
|
0 |
0 |
if (!self->connected) return 0; |
|
6134
|
0 |
0 |
if (self->send_count > 0) { |
|
6140
|
0 |
0 |
if (ngx_queue_empty(&self->send_queue) && self->pending_count == 0 |
|
|
0 |
0 |
if (ngx_queue_empty(&self->send_queue) && self->pending_count == 0 |
|
6141
|
0 |
0 |
&& self->on_drain) { |
|
6144
|
0 |
0 |
if (fire_zero_arg_cb(self, drain_cb, "drain")) { |
|
6152
|
0 |
0 |
if (ngx_queue_empty(&self->send_queue) && self->pending_count == 0 |
|
|
0 |
0 |
if (ngx_queue_empty(&self->send_queue) && self->pending_count == 0 |
|
6153
|
0 |
0 |
&& self->keepalive > 0 && !self->ka_timing) { |
|
|
0 |
0 |
&& self->keepalive > 0 && !self->ka_timing) { |
|
6158
|
0 |
0 |
if (!ngx_queue_empty(&self->send_queue)) { |
|
6176
|
0 |
0 |
if (send->on_data) { SvREFCNT_dec(send->on_data); send->on_data = NULL; } |
|
6178
|
0 |
0 |
if (self->last_query_id) { Safefree(self->last_query_id); self->last_query_id = NULL; } |
|
6179
|
0 |
0 |
if (send->query_id) { self->last_query_id = send->query_id; send->query_id = NULL; } |
|
6182
|
0 |
0 |
if (send->insert_data) { |
|
6187
|
0 |
0 |
if (send->insert_av) { |
|
6200
|
0 |
0 |
double timeout = qt > 0 ? qt : self->query_timeout; |
|
6201
|
0 |
0 |
if (timeout > 0 && !self->timing) { |
|
|
0 |
0 |
if (timeout > 0 && !self->timing) { |
|
6209
|
0 |
0 |
if (self->protocol == PROTO_NATIVE) { |
|
6210
|
0 |
0 |
if (self->insert_data || self->insert_av) |
|
|
0 |
0 |
if (self->insert_data || self->insert_av) |
|
6241
|
0 |
24 |
I_EV_API("EV::ClickHouse"); |
|
|
24 |
0 |
I_EV_API("EV::ClickHouse"); |
|
|
0 |
24 |
I_EV_API("EV::ClickHouse"); |
|
6273
|
0 |
0 |
if (self->magic != EV_CH_MAGIC) return; |
|
6277
|
0 |
0 |
if (self->timing) { |
|
6281
|
0 |
0 |
if (self->ka_timing) { |
|
6285
|
0 |
0 |
if (self->reconnect_timing) { |
|
6290
|
0 |
0 |
if (PL_dirty) { |
|
6292
|
0 |
0 |
while (!ngx_queue_empty(&self->send_queue)) { |
|
6297
|
0 |
0 |
if (send->insert_data) Safefree(send->insert_data); |
|
6298
|
0 |
0 |
if (send->insert_av) SvREFCNT_dec(send->insert_av); |
|
6299
|
0 |
0 |
if (send->on_data) SvREFCNT_dec(send->on_data); |
|
6303
|
0 |
0 |
while (!ngx_queue_empty(&self->cb_queue)) { |
|
6307
|
0 |
0 |
if (cbt->on_data) SvREFCNT_dec(cbt->on_data); |
|
6312
|
0 |
0 |
#ifdef HAVE_OPENSSL |
|
6313
|
0 |
0 |
if (self->ssl) { SSL_free(self->ssl); self->ssl = NULL; } |
|
6314
|
0 |
0 |
if (self->ssl_ctx) { SSL_CTX_free(self->ssl_ctx); self->ssl_ctx = NULL; } |
|
6315
|
0 |
0 |
#endif |
|
6316
|
0 |
0 |
if (self->fd >= 0) close(self->fd); |
|
6317
|
0 |
0 |
CLEAR_STR(self->host); |
|
6318
|
0 |
0 |
CLEAR_STR(self->user); |
|
6319
|
0 |
0 |
CLEAR_STR(self->password); |
|
6320
|
0 |
0 |
CLEAR_STR(self->database); |
|
6321
|
0 |
0 |
CLEAR_STR(self->session_id); |
|
6322
|
0 |
0 |
CLEAR_STR(self->tls_ca_file); |
|
6323
|
0 |
0 |
CLEAR_STR(self->server_name); |
|
6324
|
0 |
0 |
CLEAR_STR(self->server_display_name); |
|
6325
|
0 |
0 |
CLEAR_STR(self->server_timezone); |
|
6326
|
0 |
0 |
CLEAR_STR(self->last_query_id); |
|
6327
|
0 |
0 |
CLEAR_STR(self->insert_data); |
|
6328
|
0 |
0 |
CLEAR_STR(self->insert_err); |
|
6329
|
0 |
0 |
CLEAR_STR(self->recv_buf); |
|
6330
|
0 |
0 |
CLEAR_STR(self->send_buf); |
|
6331
|
0 |
0 |
CLEAR_SV(self->native_rows); |
|
6332
|
0 |
0 |
CLEAR_SV(self->native_col_names); |
|
6333
|
0 |
0 |
CLEAR_SV(self->native_col_types); |
|
6334
|
0 |
0 |
CLEAR_SV(self->native_totals); |
|
6335
|
0 |
0 |
CLEAR_SV(self->native_extremes); |
|
6336
|
0 |
0 |
CLEAR_SV(self->default_settings); |
|
6337
|
0 |
0 |
CLEAR_SV(self->on_disconnect); |
|
6338
|
0 |
0 |
CLEAR_SV(self->on_drain); |
|
6343
|
0 |
0 |
} |
|
6346
|
0 |
0 |
return; /* inner DESTROY already freed self */ |
|
6351
|
0 |
0 |
SSL_free(self->ssl); |
|
6356
|
0 |
0 |
self->ssl_ctx = NULL; |
|
6364
|
0 |
0 |
|
|
6365
|
0 |
0 |
self->loop = NULL; |
|
6366
|
0 |
0 |
self->connected = 0; |
|
6367
|
0 |
0 |
|
|
6368
|
0 |
0 |
CLEAR_SV(self->on_connect); |
|
6369
|
0 |
0 |
CLEAR_SV(self->on_error); |
|
6370
|
0 |
0 |
CLEAR_SV(self->on_progress); |
|
6371
|
0 |
0 |
CLEAR_SV(self->on_disconnect); |
|
6372
|
0 |
0 |
CLEAR_SV(self->on_drain); |
|
6373
|
0 |
0 |
CLEAR_SV(self->on_trace); |
|
6374
|
0 |
0 |
CLEAR_STR(self->last_query_id); |
|
6375
|
0 |
0 |
CLEAR_STR(self->host); |
|
6376
|
0 |
0 |
CLEAR_STR(self->user); |
|
6377
|
0 |
0 |
CLEAR_STR(self->password); |
|
6378
|
0 |
0 |
CLEAR_STR(self->database); |
|
6379
|
0 |
0 |
CLEAR_STR(self->session_id); |
|
6380
|
0 |
0 |
CLEAR_STR(self->tls_ca_file); |
|
6381
|
0 |
0 |
CLEAR_STR(self->server_name); |
|
6382
|
0 |
0 |
CLEAR_STR(self->server_display_name); |
|
6383
|
0 |
0 |
CLEAR_STR(self->server_timezone); |
|
6384
|
0 |
0 |
CLEAR_SV(self->native_rows); |
|
6386
|
0 |
0 |
CLEAR_SV(self->native_col_types); |
|
6387
|
0 |
0 |
CLEAR_SV(self->native_totals); |
|
6388
|
0 |
0 |
CLEAR_SV(self->native_extremes); |
|
6389
|
0 |
0 |
lc_free_dicts(self); |
|
6390
|
0 |
0 |
CLEAR_SV(self->default_settings); |
|
6391
|
0 |
0 |
CLEAR_STR(self->insert_data); |
|
6394
|
0 |
0 |
CLEAR_STR(self->recv_buf); |
|
6408
|
0 |
0 |
CLEAR_STR(self->tls_ca_file); |
|
6416
|
0 |
0 |
if (self->connected || self->connecting) { |
|
|
0 |
0 |
if (self->connected || self->connecting) { |
|
6419
|
0 |
0 |
if (has_http_unsafe_chars(host) || has_http_unsafe_chars(user) || |
|
6420
|
0 |
0 |
has_http_unsafe_chars(password) || has_http_unsafe_chars(database)) { |
|
6424
|
0 |
0 |
CLEAR_STR(self->host); |
|
6425
|
0 |
0 |
CLEAR_STR(self->user); |
|
6426
|
0 |
0 |
CLEAR_STR(self->password); |
|
6427
|
0 |
0 |
CLEAR_STR(self->database); |
|
6442
|
0 |
0 |
if (NULL == self->host) { |
|
6446
|
0 |
0 |
if (cancel_pending(self, "connection reset")) return; |
|
6455
|
0 |
0 |
if (cancel_pending(self, "connection finished")) return; |
|
6472
|
0 |
0 |
if (items == 3) { |
|
6474
|
0 |
0 |
} else if (items == 4) { |
|
6475
|
0 |
0 |
if (!(SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVHV)) |
|
|
0 |
0 |
if (!(SvROK(ST(2)) && SvTYPE(SvRV(ST(2))) == SVt_PVHV)) |
|
6483
|
0 |
0 |
if (!self->connected && !self->connecting) { |
|
|
0 |
0 |
if (!self->connected && !self->connecting) { |
|
6486
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) { |
|
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) { |
|
6490
|
0 |
0 |
if (self->protocol == PROTO_NATIVE && (self->insert_data || self->insert_av)) { |
|
|
0 |
0 |
if (self->protocol == PROTO_NATIVE && (self->insert_data || self->insert_av)) { |
|
|
0 |
0 |
if (self->protocol == PROTO_NATIVE && (self->insert_data || self->insert_av)) { |
|
6498
|
0 |
0 |
if (settings) { |
|
6502
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) { |
|
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) { |
|
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) { |
|
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVHV) { |
|
6509
|
0 |
0 |
while ((pe = hv_iternext(phv))) { |
|
6523
|
0 |
0 |
if (svp) |
|
6526
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) |
|
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) |
|
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) |
|
|
0 |
0 |
if (svp && SvOK(*svp) && SvROK(*svp) && SvTYPE(SvRV(*svp)) == SVt_PVCV) |
|
6529
|
0 |
0 |
if (svp && SvOK(*svp)) |
|
|
0 |
0 |
if (svp && SvOK(*svp)) |
|
6535
|
0 |
0 |
if (raw && self->protocol == PROTO_NATIVE) { |
|
|
0 |
0 |
if (raw && self->protocol == PROTO_NATIVE) { |
|
6536
|
0 |
0 |
if (settings_copy) SvREFCNT_dec((SV*)settings_copy); |
|
6540
|
0 |
0 |
if (on_data_sv && self->protocol == PROTO_HTTP) { |
|
|
0 |
0 |
if (on_data_sv && self->protocol == PROTO_HTTP) { |
|
6541
|
0 |
0 |
if (settings_copy) SvREFCNT_dec((SV*)settings_copy); |
|
6545
|
0 |
0 |
if (self->protocol == PROTO_HTTP) { |
|
6558
|
0 |
0 |
if (on_data_sv) s->on_data = SvREFCNT_inc(on_data_sv); |
|
6560
|
0 |
0 |
if (settings) { |
|
6562
|
0 |
0 |
if (qid && SvOK(*qid)) { |
|
|
0 |
0 |
if (qid && SvOK(*qid)) { |
|
6571
|
0 |
0 |
if (settings_copy) SvREFCNT_dec((SV*)settings_copy); |
|
6575
|
0 |
0 |
if (self->connected && self->callback_depth == 0) |
|
|
0 |
0 |
if (self->connected && self->callback_depth == 0) |
|
6593
|
0 |
0 |
if (items == 4) { |
|
6595
|
0 |
0 |
} else if (items == 5) { |
|
6596
|
0 |
0 |
if (!(SvROK(ST(3)) && SvTYPE(SvRV(ST(3))) == SVt_PVHV)) |
|
|
0 |
0 |
if (!(SvROK(ST(3)) && SvTYPE(SvRV(ST(3))) == SVt_PVHV)) |
|
6604
|
0 |
0 |
if (!self->connected && !self->connecting) { |
|
|
0 |
0 |
if (!self->connected && !self->connecting) { |
|
6607
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) { |
|
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) { |
|
6614
|
0 |
0 |
if (SvROK(data_sv) && SvTYPE(SvRV(data_sv)) == SVt_PVAV) { |
|
|
0 |
0 |
if (SvROK(data_sv) && SvTYPE(SvRV(data_sv)) == SVt_PVAV) { |
|
6619
|
0 |
0 |
if (self->protocol == PROTO_HTTP) { |
|
6624
|
0 |
0 |
if (data_is_av) { |
|
6635
|
0 |
0 |
if (tsv_buf) Safefree(tsv_buf); |
|
6644
|
0 |
0 |
if (self->insert_data || self->insert_av) { |
|
|
0 |
0 |
if (self->insert_data || self->insert_av) { |
|
6661
|
0 |
0 |
if (settings) { |
|
6663
|
0 |
0 |
if (qid && SvOK(*qid)) { |
|
|
0 |
0 |
if (qid && SvOK(*qid)) { |
|
6675
|
0 |
0 |
if (self->protocol == PROTO_NATIVE) { |
|
6676
|
0 |
0 |
if (data_is_av) { |
|
6681
|
0 |
0 |
Newx(s->insert_data, data_len > 0 ? data_len : 1, char); |
|
6682
|
0 |
0 |
if (data_len > 0) |
|
6692
|
0 |
0 |
if (self->connected && self->callback_depth == 0) |
|
|
0 |
0 |
if (self->connected && self->callback_depth == 0) |
|
6704
|
0 |
0 |
if (!self->connected && !self->connecting) { |
|
|
0 |
0 |
if (!self->connected && !self->connecting) { |
|
6707
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) { |
|
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) { |
|
6711
|
0 |
0 |
if (self->protocol == PROTO_HTTP) { |
|
6724
|
0 |
0 |
if (self->connected && self->callback_depth == 0) |
|
|
0 |
0 |
if (self->connected && self->callback_depth == 0) |
|
6759
|
0 |
0 |
RETVAL = self->connected ? 1 : 0; |
|
6768
|
0 |
0 |
RETVAL = self->pending_count; |
|
6777
|
0 |
0 |
if (self->server_name) { |
|
6785
|
0 |
0 |
if (n >= (int)sizeof(buf)) n = (int)sizeof(buf) - 1; |
|
6798
|
0 |
0 |
if (self->server_revision) { |
|
6804
|
0 |
0 |
if (n >= (int)sizeof(buf)) n = (int)sizeof(buf) - 1; |
|
6821
|
0 |
0 |
if (cancel_pending(self, "skipped")) return; |
|
6822
|
0 |
0 |
CLEAR_STR(self->insert_data); |
|
6824
|
0 |
0 |
CLEAR_SV(self->insert_av); |
|
6825
|
0 |
0 |
CLEAR_STR(self->insert_err); |
|
6826
|
0 |
0 |
if (had_inflight) |
|
6848
|
0 |
0 |
CLEAR_STR(self->session_id); |
|
6864
|
0 |
0 |
self->tls_enabled = val; |
|
6874
|
0 |
0 |
if (!(SvROK(href) && SvTYPE(SvRV(href)) == SVt_PVHV)) |
|
|
0 |
0 |
if (!(SvROK(href) && SvTYPE(SvRV(href)) == SVt_PVHV)) |
|
6876
|
0 |
0 |
if (self->default_settings) |
|
6895
|
0 |
0 |
if (self->server_timezone) |
|
6935
|
0 |
0 |
if (self->native_col_names) |
|
6947
|
0 |
0 |
if (self->last_query_id) |
|
6968
|
0 |
0 |
if (self->native_col_types) |
|
6980
|
0 |
0 |
if (self->native_totals) |
|
6992
|
0 |
0 |
if (self->native_extremes) |
|
7061
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) |
|
|
0 |
0 |
if (!(SvROK(cb) && SvTYPE(SvRV(cb)) == SVt_PVCV)) |
|
7063
|
0 |
0 |
CLEAR_SV(self->on_drain); |
|
7064
|
0 |
0 |
if (self->pending_count == 0 && ngx_queue_empty(&self->send_queue)) { |
|
|
0 |
0 |
if (self->pending_count == 0 && ngx_queue_empty(&self->send_queue)) { |
|
7076
|
0 |
0 |
if (self->protocol == PROTO_NATIVE && self->send_count > 0) { |
|
|
0 |
0 |
if (self->protocol == PROTO_NATIVE && self->send_count > 0) { |
|
7085
|
0 |
0 |
if (!self->writing) start_writing(self); |
|
7087
|
0 |
0 |
} else if (self->protocol == PROTO_HTTP && self->send_count > 0) { |
|
|
0 |
0 |
} else if (self->protocol == PROTO_HTTP && self->send_count > 0) { |
|
7089
|
0 |
0 |
CLEAR_SV(self->native_rows); |
|
7090
|
0 |
0 |
if (cancel_pending(self, "query cancelled")) return; |
|
7092
|
0 |
0 |
if (self->auto_reconnect && self->host) |
|
|
0 |
0 |
if (self->auto_reconnect && self->host) |