clickhouse-native 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c874b72697637755a30f9a8a22edad7c35050878e7e7d1e9260f2cd7dc06c137
4
- data.tar.gz: 4df29895e45102db083fc6f21718f4845fcd944fba72bea95f1c3b2dc6549c0a
3
+ metadata.gz: 51aa32b5ec77367fcc08b8df05c2449bb8e99b7f1cc3b7cc331d83c408cea32c
4
+ data.tar.gz: 3b28a9d0cde5d7c827f212bb5ecde1d0dee21f5a8e4cc2faaa20de06534f59d5
5
5
  SHA512:
6
- metadata.gz: 55a54773a8f42cfea9029973966fc245442c8ccf732808750d61374b8f661aaba0bc9869567dd37599a1128367ff83161a73b21c33987f9d88138cf467c08571
7
- data.tar.gz: ffea3e3c143e8bf311573f7c7864b8c2794efebcdf9dcdc090e4ec3a54436d4f6d5df63bd76119e42301138e887ce9ebbe536009bc9518a9d8067a67042f4f34
6
+ metadata.gz: 825b57cd31290f4717a5e38d7b0d08c7949e455c23246913f1885db868a63b0b44a600f9527dd5f7175f889d1e9327f7b75af4ada2075aa5d2b7284f0b88184c
7
+ data.tar.gz: 6c178edde2ba5ffbd1bee2f439e8d5c2d3dd3932c80442b9da34090cfc3286388a2cf3b834ff43a476aa7c68d1aaedc91409b48287a3e940383d8f8d98a75222
@@ -31,12 +31,21 @@ static VALUE rb_cClient;
31
31
  static VALUE err_base, err_connection, err_timeout, err_protocol,
32
32
  err_server, err_encoder, err_decoder, err_unsupported;
33
33
 
34
- // Internal exception used to tag encoder failures and drive them through
35
- // raise_mapped_ex -> err_encoder without rb_raising from inside a try block.
34
+ // Internal exceptions used to tag encoder / decoder failures and drive
35
+ // them through raise_mapped_ex -> err_encoder / err_unsupported /
36
+ // err_decoder without rb_raising from inside a try block. Critically,
37
+ // throwing (instead of rb_raise) lets the outer catch run
38
+ // ResetConnection() so the pooled client doesn't stay mid-packet.
36
39
  namespace chn {
37
40
  class EncoderFailure : public clickhouse::Error {
38
41
  using clickhouse::Error::Error;
39
42
  };
43
+ class UnsupportedType : public clickhouse::Error {
44
+ using clickhouse::Error::Error;
45
+ };
46
+ class DecoderFailure : public clickhouse::Error {
47
+ using clickhouse::Error::Error;
48
+ };
40
49
  } // namespace chn
41
50
 
42
51
  // ------------------------------------------------------------------
@@ -57,6 +66,12 @@ static void raise_mapped_ex(const std::exception& e) {
57
66
  if (dynamic_cast<const chn::EncoderFailure*>(&e)) {
58
67
  rb_raise(err_encoder, "%s", e.what());
59
68
  }
69
+ if (dynamic_cast<const chn::UnsupportedType*>(&e)) {
70
+ rb_raise(err_unsupported, "%s", e.what());
71
+ }
72
+ if (dynamic_cast<const chn::DecoderFailure*>(&e)) {
73
+ rb_raise(err_decoder, "%s", e.what());
74
+ }
60
75
  if (dynamic_cast<const ProtocolError*>(&e)) {
61
76
  rb_raise(err_protocol, "%s", e.what());
62
77
  }
@@ -212,7 +227,7 @@ static VALUE value_at(const ColumnRef& col, size_t idx) {
212
227
  auto tuples = map_col->GetAsColumn(idx);
213
228
  auto tuple = tuples->As<ColumnTuple>();
214
229
  if (!tuple || tuple->TupleSize() != 2) {
215
- rb_raise(err_decoder, "clickhouse-native: malformed Map column");
230
+ throw chn::DecoderFailure("clickhouse-native: malformed Map column");
216
231
  }
217
232
  auto keys = (*tuple)[0];
218
233
  auto vals = (*tuple)[1];
@@ -242,9 +257,10 @@ static VALUE value_at(const ColumnRef& col, size_t idx) {
242
257
  }
243
258
 
244
259
  default:
245
- rb_raise(err_unsupported,
246
- "clickhouse-native: unsupported column type %s (code=%d)",
247
- type->GetName().c_str(), static_cast<int>(type->GetCode()));
260
+ throw chn::UnsupportedType(
261
+ std::string("clickhouse-native: unsupported column type ")
262
+ + type->GetName()
263
+ + " (code=" + std::to_string(static_cast<int>(type->GetCode())) + ")");
248
264
  }
249
265
  return Qnil;
250
266
  }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClickhouseNative
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clickhouse-native
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuri Smirnov