Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions clickhouse.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,6 @@ const char *chc_type_tuple_field_name(const chc_type *t, size_t i,
/* Return an aggregate function name without parameters, or NULL when absent */
const char *chc_type_agg_function(const chc_type *t, size_t *out_len);

/* Reproduce the printable type name into buf. Returns the number of bytes
* that would have been written (snprintf-style); use to size buf on a
* second pass when the return value >= buf_len. buf may be NULL when
* buf_len == 0 (length query). */
size_t chc_type_format(const chc_type *t, char *buf, size_t buf_len);

/* -------------------------------------------------------------------------- */
/* Columns */
/* -------------------------------------------------------------------------- */
Expand Down Expand Up @@ -1881,21 +1875,6 @@ chc_type_parse(const char *name, size_t name_len,
return CHC_OK;
}

size_t
chc_type_format(const chc_type *t, char *buf, size_t buf_len)
{
if (!t) return 0;
if (t->name && t->name_len) {
if (buf && buf_len) {
size_t take = t->name_len < buf_len - 1 ? t->name_len : buf_len - 1;
memcpy(buf, t->name, take);
buf[take] = '\0';
}
return t->name_len;
}
return 0;
}

/* -------- column internals ---------- */
/* Public API defines struct chc_column */

Expand Down
6 changes: 0 additions & 6 deletions doc/clickhouse.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,8 @@ const char *chc_type_tuple_field_name (const chc_type *t, size_t i,
size_t *out_len);
const char *chc_type_agg_function (const chc_type *t,
size_t *out_len);

size_t chc_type_format (const chc_type *t,
char *buf, size_t buf_len);
```

`chc_type_format` is snprintf-style: pass `NULL`/0 to query length, then
allocate & call again.

`chc_type_tuple_field_name` covers `Nested` as well as `Tuple`; both label
their children, `Nested(a UInt32, b String)` reading back `a` & `b`.

Expand Down
22 changes: 4 additions & 18 deletions test/test_block_compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define CLICKHOUSE_TEST_BLOCK_COMPARE_H

#include <stdint.h>
#include <stdlib.h>
#include <string.h>

static int test_col_eq(const chc_column *a, const chc_column *b);
Expand All @@ -15,23 +14,10 @@ static int
test_type_eq(const chc_type *a, const chc_type *b)
{
if (!a || !b) return a == b;
size_t na = chc_type_format(a, NULL, 0);
size_t nb = chc_type_format(b, NULL, 0);
if (na != nb) return 0;

char *sa = malloc(na + 1);
char *sb = malloc(nb + 1);
if (!sa || !sb) {
free(sa);
free(sb);
return 0;
}
chc_type_format(a, sa, na + 1);
chc_type_format(b, sb, nb + 1);
int eq = memcmp(sa, sb, na) == 0;
free(sa);
free(sb);
return eq;
size_t na, nb;
const char *sa = chc_type_name(a, &na);
const char *sb = chc_type_name(b, &nb);
return na == nb && memcmp(sa, sb, na) == 0;
}

static int
Expand Down
15 changes: 3 additions & 12 deletions test/test_block_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -961,18 +961,9 @@ static void test_type_parse_roundtrip(void) {
fail_count++;
continue;
}
char buf[128];
size_t need = chc_type_format(t, buf, sizeof buf);
if (need >= sizeof buf) {
fprintf(stderr, "%s: format overflow\n", types[i]);
fail_count++;
}
/* Round-trip should be identical or a normalized form */
if (strcmp(types[i], buf) != 0) {
/* For Enum the input has spaces in the formatted output too, OK */
fprintf(stderr, "%s: round-trip mismatch -> %s\n", types[i], buf);
/* not a hard fail: we exact-match the source string today */
}
size_t len;
const char *nm = chc_type_name(t, &len);
CHECK_STR_EQ(nm, len, types[i]);
chc_type_destroy(t, &al);
}
}
Expand Down
11 changes: 0 additions & 11 deletions test/test_type_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,6 @@ test_decimal_precision(void)
chc_type_destroy(i32, &al);
}

static void
test_format_unnamed(void)
{
current_test = "format_unnamed";
chc_type t = {}; /* only the parser fills in name */
char buf[8] = "junk";
CHECK_EQ_U64(chc_type_format(&t, buf, sizeof buf), 0);
CHECK_EQ_U64(chc_type_format(NULL, buf, sizeof buf), 0);
}

static void
test_datetime_timezone(void)
{
Expand Down Expand Up @@ -360,7 +350,6 @@ main(void)
test_depth_limit();
test_accessors();
test_decimal_precision();
test_format_unnamed();
test_datetime_timezone();
test_aggregate_function();
test_nested_json_params();
Expand Down