clickhouse-c-rs 0.2.2

Rust bindings for clickhouse-c, the header-only C client for the ClickHouse Native wire format
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
//! Raw FFI bindings for clickhouse-c.
//!
//! Structures and functions mirror public C headers. `build.rs` reads integer
//! constants from bundled headers and generates corresponding Rust constants.

#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(dead_code)]

use core::ffi::{c_char, c_int, c_void};

/* C enum types */

pub type chc_kind = c_int;
pub type chc_col_kind = c_int;
pub type chc_interval_unit = c_int;
pub type chc_compression = c_int;
pub type chc_packet_kind = c_int;

include!(concat!(env!("OUT_DIR"), "/sys_constants.rs"));

/* Errors */

#[repr(C)]
pub struct chc_err {
    pub msg: [c_char; CHC_ERR_MSG_LEN],
}

impl chc_err {
    pub const fn zeroed() -> Self {
        Self {
            msg: [0; CHC_ERR_MSG_LEN],
        }
    }
}

/* Allocator */

#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_alloc {
    pub ud: *mut c_void,
    pub alloc: Option<unsafe extern "C" fn(ud: *mut c_void, bytes: usize) -> *mut c_void>,
    pub realloc: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            p: *mut c_void,
            old_bytes: usize,
            new_bytes: usize,
        ) -> *mut c_void,
    >,
    pub free: Option<unsafe extern "C" fn(ud: *mut c_void, p: *mut c_void, bytes: usize)>,
}

unsafe extern "C" {
    pub fn chc_alloc_stdlib() -> chc_alloc;
}

/* Local C helpers from src/wrapper.c */

unsafe extern "C" {
    // Use same monotonic clock as POSIX backend deadlines
    pub fn chc_rs_monotonic_us() -> i64;
}

/* I/O */

// Public callback table from clickhouse.h
#[repr(C)]
pub struct chc_io {
    pub ud: *mut c_void,
    pub read: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            buf: *mut c_void,
            len: usize,
            out_n: *mut usize,
            err: *mut chc_err,
        ) -> c_int,
    >,
    pub write: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            buf: *const c_void,
            len: usize,
            err: *mut chc_err,
        ) -> c_int,
    >,
    pub check_cancel: Option<unsafe extern "C" fn(ud: *mut c_void) -> c_int>,
}

// Implementation-private buffered reader allocated through C helpers
#[repr(C)]
pub struct chc_in {
    _opaque: [u8; 0],
}

unsafe extern "C" {
    // Supports callback-backed and submitted-input modes
    pub fn chc_in_init(
        input: *mut chc_in,
        io: *mut chc_io,
        al: *const chc_alloc,
        cap: usize,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_in_init_ioless(input: *mut chc_in, al: *const chc_alloc) -> c_int;
    pub fn chc_in_submit(
        input: *mut chc_in,
        buf: *const c_void,
        len: usize,
        err: *mut chc_err,
    ) -> c_int;
    /// Returns number of unconsumed buffered bytes.
    pub fn chc_in_available(input: *const chc_in) -> usize;
    /// Removes consumed bytes and compacts buffer.
    pub fn chc_in_reset(input: *mut chc_in);
    pub fn chc_in_free(input: *mut chc_in);
}

// Public POSIX file descriptor backend state from clickhouse-posix-io.h
#[repr(C)]
pub struct chc_posix_io {
    pub fd: c_int,
    pub check_cancel: Option<unsafe extern "C" fn(ud: *mut c_void) -> bool>,
    pub cancel_ud: *mut c_void,
    // Absolute monotonic deadline in microseconds, zero disables timeout
    pub deadline_us: i64,
}

unsafe extern "C" {
    pub fn chc_posix_io_init(
        state: *mut chc_posix_io,
        out_io: *mut chc_io,
        fd: c_int,
        check_cancel: Option<unsafe extern "C" fn(ud: *mut c_void) -> bool>,
        cancel_ud: *mut c_void,
    );
    pub fn chc_posix_io_set_deadline(state: *mut chc_posix_io, deadline_us: i64);
}

/* Type syntax tree */

#[repr(C)]
pub struct chc_type {
    _opaque: [u8; 0],
}

unsafe extern "C" {
    pub fn chc_type_parse(
        name: *const c_char,
        name_len: usize,
        al: *const chc_alloc,
        out: *mut *mut chc_type,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_type_destroy(t: *mut chc_type, al: *const chc_alloc);

    pub fn chc_type_kind(t: *const chc_type) -> chc_kind;
    pub fn chc_type_n_children(t: *const chc_type) -> usize;
    pub fn chc_type_child(t: *const chc_type, i: usize) -> *const chc_type;

    pub fn chc_type_fixed_size(t: *const chc_type) -> c_int;
    pub fn chc_type_elem_size(t: *const chc_type) -> usize;
    pub fn chc_type_decimal_precision(t: *const chc_type) -> c_int;
    pub fn chc_type_decimal_scale(t: *const chc_type) -> c_int;
    pub fn chc_type_datetime64_scale(t: *const chc_type) -> c_int;
    pub fn chc_type_interval_unit(t: *const chc_type) -> chc_interval_unit;
    pub fn chc_type_qbit_dimension(t: *const chc_type) -> usize;
    pub fn chc_type_qbit_element_size(t: *const chc_type) -> usize;
    pub fn chc_type_timezone(t: *const chc_type, out_len: *mut usize) -> *const c_char;
    pub fn chc_type_name(t: *const chc_type, out_len: *mut usize) -> *const c_char;

    pub fn chc_type_enum_count(t: *const chc_type) -> usize;
    pub fn chc_type_enum_at(
        t: *const chc_type,
        i: usize,
        name: *mut *const c_char,
        name_len: *mut usize,
        value: *mut i64,
    );

    pub fn chc_type_tuple_field_name(
        t: *const chc_type,
        i: usize,
        out_len: *mut usize,
    ) -> *const c_char;
    pub fn chc_type_agg_function(t: *const chc_type, out_len: *mut usize) -> *const c_char;

    pub fn chc_type_format(t: *const chc_type, buf: *mut c_char, buf_len: usize) -> usize;
}

/* Columns */

// Public column layout from clickhouse.h, checked by tests/layout.rs
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_column_fixed {
    pub data: *mut c_void,
    pub elem_size: usize,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_column_str {
    pub data: *mut u8,
    pub offsets: *mut u64,
    pub bytes: usize,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_column_nullable {
    pub null_map: *mut u8,
    pub inner: *mut chc_column,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_column_array {
    pub offsets: *mut u64,
    pub values: *mut chc_column,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_column_tuple {
    pub children: *mut *mut chc_column,
    pub arity: usize,
}
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_column_lc {
    pub key_size: c_int,
    pub keys: *mut c_void,
    pub dict: *mut chc_column,
    pub dict_n: usize,
}

// `layout` selects active member of anonymous C union
#[repr(C)]
pub union chc_column_payload {
    pub fixed: chc_column_fixed,
    pub str_: chc_column_str,
    pub nullable: chc_column_nullable,
    pub array: chc_column_array,
    pub tuple: chc_column_tuple,
    pub lc: chc_column_lc,
}

#[repr(C)]
pub struct chc_column {
    pub layout: chc_col_kind,
    pub n_rows: usize,
    pub payload: chc_column_payload,
}

unsafe extern "C" {
    // Builders borrow input data and child nodes without allocating
    pub fn chc_build_fixed(data: *const c_void, elem_size: usize, n_rows: usize) -> chc_column;
    pub fn chc_build_string(offsets: *const u64, data: *const u8, n_rows: usize) -> chc_column;
    pub fn chc_build_nullable(null_map: *const u8, inner: *mut chc_column) -> chc_column;
    pub fn chc_build_array(
        offsets: *const u64,
        n_rows: usize,
        values: *mut chc_column,
    ) -> chc_column;
    pub fn chc_build_tuple(children: *mut *mut chc_column, arity: usize) -> chc_column;
    pub fn chc_build_lc(
        key_size: c_int,
        keys: *const c_void,
        n_rows: usize,
        dict: *mut chc_column,
    ) -> chc_column;
}

unsafe extern "C" {
    pub fn chc_column_layout(c: *const chc_column) -> chc_col_kind;
    pub fn chc_column_n_rows(c: *const chc_column) -> usize;
    pub fn chc_column_fixed_data(c: *const chc_column, elem_size: *mut usize) -> *const c_void;
    pub fn chc_column_string_data(c: *const chc_column) -> *const u8;
    pub fn chc_column_string_offsets(c: *const chc_column) -> *const u64;
    pub fn chc_column_null_map(c: *const chc_column) -> *const u8;
    pub fn chc_column_nullable_inner(c: *const chc_column) -> *const chc_column;
    pub fn chc_column_array_offsets(c: *const chc_column) -> *const u64;
    pub fn chc_column_array_values(c: *const chc_column) -> *const chc_column;
    pub fn chc_column_tuple_arity(c: *const chc_column) -> usize;
    pub fn chc_column_tuple_child(c: *const chc_column, i: usize) -> *const chc_column;
    pub fn chc_column_lc_key_size(c: *const chc_column) -> c_int;
    pub fn chc_column_lc_keys(c: *const chc_column) -> *const c_void;
    pub fn chc_column_lc_dict(c: *const chc_column) -> *const chc_column;
    pub fn chc_column_validate(c: *const chc_column, err: *mut chc_err) -> c_int;
}

/* Block reader */

#[repr(C)]
pub struct chc_block {
    _opaque: [u8; 0],
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_block_opts {
    pub has_block_info: bool,
    pub has_custom_serialization: bool,
    pub read_buffer_bytes: usize,
}

impl chc_block_opts {
    pub const fn zeroed() -> Self {
        Self {
            has_block_info: false,
            has_custom_serialization: false,
            read_buffer_bytes: 0,
        }
    }
}

unsafe extern "C" {
    // C helpers allocate implementation-private buffered reader
    pub fn chc_rs_in_new(
        io: *mut chc_io,
        al: *const chc_alloc,
        cap: usize,
        out: *mut *mut chc_in,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_rs_in_new_ioless(
        al: *const chc_alloc,
        out: *mut *mut chc_in,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_rs_in_destroy(input: *mut chc_in, al: *const chc_alloc);

    pub fn chc_block_read(
        input: *mut chc_in,
        al: *const chc_alloc,
        opts: *const chc_block_opts,
        out: *mut *mut chc_block,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_block_destroy(b: *mut chc_block, al: *const chc_alloc);

    pub fn chc_block_n_rows(b: *const chc_block) -> usize;
    pub fn chc_block_n_columns(b: *const chc_block) -> usize;
    pub fn chc_block_column_name(
        b: *const chc_block,
        i: usize,
        out_len: *mut usize,
    ) -> *const c_char;
    pub fn chc_block_column_type(b: *const chc_block, i: usize) -> *const chc_type;
    pub fn chc_block_column(b: *const chc_block, i: usize) -> *const chc_column;

    pub fn chc_block_is_overflows(b: *const chc_block) -> bool;
    pub fn chc_block_bucket_num(b: *const chc_block) -> i32;
}

/* Block builder */

// Block column borrows name, type, and column tree until write completes
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_block_col {
    pub name: *const c_char,
    pub name_len: usize,
    pub type_: *const chc_type,
    pub col: *const chc_column,
}

impl chc_block_col {
    pub const fn zeroed() -> Self {
        Self {
            name: core::ptr::null(),
            name_len: 0,
            type_: core::ptr::null(),
            col: core::ptr::null(),
        }
    }
}

// Builder references caller-provided column storage
#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_block_builder {
    pub cols: *mut chc_block_col,
    pub n_cols: usize,
    pub n_rows: usize,
}

impl chc_block_builder {
    pub const fn zeroed() -> Self {
        Self {
            cols: core::ptr::null_mut(),
            n_cols: 0,
            n_rows: 0,
        }
    }
}

unsafe extern "C" {
    pub fn chc_block_builder_init(bb: *mut chc_block_builder, cols: *mut chc_block_col);
    pub fn chc_block_builder_append(
        bb: *mut chc_block_builder,
        name: *const c_char,
        name_len: usize,
        t: *const chc_type,
        col: *const chc_column,
    );

    pub fn chc_block_write_cols(
        io: *mut chc_io,
        cols: *const chc_block_col,
        n_cols: usize,
        n_rows: usize,
        opts: *const chc_block_opts,
        err: *mut chc_err,
    ) -> c_int;

    pub fn chc_block_write(
        io: *mut chc_io,
        bb: *const chc_block_builder,
        opts: *const chc_block_opts,
        err: *mut chc_err,
    ) -> c_int;
}

/* Compression */

#[repr(C)]
pub struct chc_codec {
    pub ud: *mut c_void,
    pub lz4_compress: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            src: *const c_void,
            src_len: usize,
            dst: *mut c_void,
            dst_cap: usize,
            dst_n: *mut usize,
            err: *mut chc_err,
        ) -> c_int,
    >,
    pub lz4_decompress: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            src: *const c_void,
            src_len: usize,
            dst: *mut c_void,
            original_size: usize,
            err: *mut chc_err,
        ) -> c_int,
    >,
    pub zstd_compress: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            src: *const c_void,
            src_len: usize,
            dst: *mut c_void,
            dst_cap: usize,
            dst_n: *mut usize,
            err: *mut chc_err,
        ) -> c_int,
    >,
    pub zstd_decompress: Option<
        unsafe extern "C" fn(
            ud: *mut c_void,
            src: *const c_void,
            src_len: usize,
            dst: *mut c_void,
            original_size: usize,
            err: *mut chc_err,
        ) -> c_int,
    >,
    pub lz4_bound: Option<unsafe extern "C" fn(src_len: usize) -> usize>,
    pub zstd_bound: Option<unsafe extern "C" fn(src_len: usize) -> usize>,
}

unsafe extern "C" {
    pub fn chc_cityhash128(data: *const c_void, len: usize, out_lo: *mut u64, out_hi: *mut u64);
}

#[cfg(feature = "lz4")]
unsafe extern "C" {
    pub fn chc_lz4_codec_init(out: *mut chc_codec);
}

#[cfg(feature = "zstd")]
unsafe extern "C" {
    pub fn chc_zstd_codec_init(out: *mut chc_codec);
}

/* Native protocol client */

#[repr(C)]
pub struct chc_client_opts {
    pub client_name: *const c_char,
    pub client_version_major: u64,
    pub client_version_minor: u64,
    pub client_version_patch: u64,
    pub database: *const c_char,
    pub user: *const c_char,
    pub password: *const c_char,
    pub compression: chc_compression,
    pub codec: *const chc_codec,
    pub read_buffer_bytes: usize,
}

impl chc_client_opts {
    pub const fn zeroed() -> Self {
        Self {
            client_name: core::ptr::null(),
            client_version_major: 0,
            client_version_minor: 0,
            client_version_patch: 0,
            database: core::ptr::null(),
            user: core::ptr::null(),
            password: core::ptr::null(),
            compression: CHC_COMP_NONE,
            codec: core::ptr::null(),
            read_buffer_bytes: 0,
        }
    }
}

#[repr(C)]
pub struct chc_server_info {
    pub name: [c_char; 64],
    pub timezone: [c_char; 64],
    pub display_name: [c_char; 128],
    pub version_major: u64,
    pub version_minor: u64,
    pub version_patch: u64,
    pub revision: u64,
}

#[repr(C)]
pub struct chc_client {
    _opaque: [u8; 0],
}

#[repr(C)]
pub struct chc_exception {
    pub code: i32,
    pub name: *mut c_char,
    pub name_len: usize,
    pub display_text: *mut c_char,
    pub display_text_len: usize,
    pub stack_trace: *mut c_char,
    pub stack_trace_len: usize,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_packet_progress {
    pub rows: u64,
    pub bytes: u64,
    pub total_rows: u64,
    pub total_bytes: u64,
    pub written_rows: u64,
    pub written_bytes: u64,
    pub elapsed_ns: u64,
}

#[repr(C)]
#[derive(Clone, Copy)]
pub struct chc_packet_profile {
    pub rows: u64,
    pub blocks: u64,
    pub bytes: u64,
    pub rows_before_limit: u64,
    pub applied_limit: u8,
    pub calculated_rows_before_limit: u8,
}

// `kind` selects active member of C payload union
#[repr(C)]
pub union chc_packet_payload {
    pub block: *mut chc_block,
    pub exception: *mut chc_exception,
    pub progress: chc_packet_progress,
    pub profile: chc_packet_profile,
}

#[repr(C)]
pub struct chc_packet {
    pub kind: chc_packet_kind,
    pub payload: chc_packet_payload,
}

impl chc_packet {
    pub const fn zeroed() -> Self {
        Self {
            kind: 0,
            payload: chc_packet_payload {
                block: core::ptr::null_mut(),
            },
        }
    }
}

#[repr(C)]
pub struct chc_query_setting {
    pub name: *const c_char,
    pub value: *const c_char,
    pub important: bool,
    pub custom: bool,
}

#[repr(C)]
pub struct chc_query_param {
    pub name: *const c_char,
    pub value: *const c_char,
}

#[repr(C)]
pub struct chc_query_opts {
    pub query_id: *const c_char,
    pub query_id_len: usize,
    pub settings: *const chc_query_setting,
    pub n_settings: usize,
    pub params: *const chc_query_param,
    pub n_params: usize,
}

unsafe extern "C" {
    // Handshake rejection transfers exception ownership through `exc`
    pub fn chc_client_init(
        out: *mut *mut chc_client,
        opts: *const chc_client_opts,
        al: *const chc_alloc,
        io: *mut chc_io,
        exc: *mut *mut chc_exception,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_client_close(c: *mut chc_client);
    pub fn chc_client_server_info(c: *const chc_client) -> *const chc_server_info;
    pub fn chc_client_send_query(
        c: *mut chc_client,
        sql: *const c_char,
        sql_len: usize,
        query_id: *const c_char,
        query_id_len: usize,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_client_send_query_ex(
        c: *mut chc_client,
        sql: *const c_char,
        sql_len: usize,
        opts: *const chc_query_opts,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_client_recv_packet(
        c: *mut chc_client,
        out: *mut chc_packet,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_packet_clear(c: *mut chc_client, p: *mut chc_packet);
    pub fn chc_client_send_data(
        c: *mut chc_client,
        bb: *const chc_block_builder,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_client_send_cancel(c: *mut chc_client, err: *mut chc_err) -> c_int;
    pub fn chc_client_send_ping(c: *mut chc_client, err: *mut chc_err) -> c_int;
    pub fn chc_exception_free(e: *mut chc_exception, al: *const chc_alloc);
}

/* I/O-independent client */

#[repr(C)]
pub struct chc_async_client {
    _opaque: [u8; 0],
}

unsafe extern "C" {
    pub fn chc_async_client_init(
        out: *mut *mut chc_async_client,
        opts: *const chc_client_opts,
        al: *const chc_alloc,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_async_client_free(c: *mut chc_async_client);

    pub fn chc_async_submit(
        c: *mut chc_async_client,
        buf: *const c_void,
        len: usize,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_async_pending_out(c: *mut chc_async_client, buf: *mut *const u8, len: *mut usize);
    pub fn chc_async_consume_out(c: *mut chc_async_client, n: usize);

    // Handshake rejection transfers exception ownership through `exc`
    pub fn chc_async_handshake(
        c: *mut chc_async_client,
        exc: *mut *mut chc_exception,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_async_send_query(
        c: *mut chc_async_client,
        sql: *const c_char,
        sql_len: usize,
        query_id: *const c_char,
        query_id_len: usize,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_async_send_data(
        c: *mut chc_async_client,
        bb: *const chc_block_builder,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_async_send_data_end(c: *mut chc_async_client, err: *mut chc_err) -> c_int;
    pub fn chc_async_recv_packet(
        c: *mut chc_async_client,
        out: *mut chc_packet,
        err: *mut chc_err,
    ) -> c_int;
    pub fn chc_async_server_info(c: *const chc_async_client) -> *const chc_server_info;
    pub fn chc_async_packet_clear(c: *mut chc_async_client, p: *mut chc_packet);
}