trilogy 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of trilogy might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aca8390c35be7813f34f018fab70db8630dbec8e1b9fa3962e5b432203ae0299
4
- data.tar.gz: ac509a03ca6f611eb87603ba55749547fe8eaad0792107dd2bf855646726fb4c
3
+ metadata.gz: 79779c19d22b6a05581eba7135cf2fd588a64ee33b59c8caf82a4dc51277bf5f
4
+ data.tar.gz: 48c88ac7fe38563810abc4f21858758f9b54f102b4abb63c81d0a41f4bd0a687
5
5
  SHA512:
6
- metadata.gz: 2d66ea74cadbc2849a53d240b2a4b0a7094a31e9b79be12b92d1691c1aede8929d6752afeed46a5e2ad0666cc7f2e1aef170c55e8ec3b2caa91f5c0be369572c
7
- data.tar.gz: b96064098c800476df66ad24eca177f3651b37679d8d634eb7301c4c97ca653e59da1f6acf3ea5e72af892fb0a8abea5d0f83378319bb73f81307cfac1fa08ac
6
+ metadata.gz: ab915961914de4e0ed847b93aae3357fe328186cd0fdf602f322c379bdd15a3d1aa935535783bfce892cb5013b41c841581c83c42ea248cc6ff0efd7abd2d6eb
7
+ data.tar.gz: 6865a1c5b9c96ff4d4eefda88cc771aff23b3ff6db8534767edbdba4a929eec1f42184ae845fe02664c1e6b8c64c72aa52f5948233d8ca35f57c510c60ef42a9
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- require "bundler/gem_helper"
1
+ require "bundler/gem_tasks"
2
2
  require "rake/extensiontask"
3
3
 
4
4
  Rake::ExtensionTask.new do |ext|
@@ -21,9 +21,9 @@ static VALUE Trilogy_DatabaseError, Trilogy_Result;
21
21
 
22
22
  static ID id_socket, id_host, id_port, id_username, id_password, id_found_rows, id_connect_timeout, id_read_timeout,
23
23
  id_write_timeout, id_keepalive_enabled, id_keepalive_idle, id_keepalive_interval, id_keepalive_count,
24
- id_ivar_fields, id_ivar_rows, id_ivar_query_time, id_password, id_database, id_ssl_ca, id_ssl_capath, id_ssl_cert,
25
- id_ssl_cipher, id_ssl_crl, id_ssl_crlpath, id_ssl_key, id_ssl_mode, id_tls_ciphersuites, id_tls_min_version,
26
- id_tls_max_version;
24
+ id_ivar_affected_rows, id_ivar_fields, id_ivar_last_insert_id, id_ivar_rows, id_ivar_query_time, id_password,
25
+ id_database, id_ssl_ca, id_ssl_capath, id_ssl_cert, id_ssl_cipher, id_ssl_crl, id_ssl_crlpath, id_ssl_key,
26
+ id_ssl_mode, id_tls_ciphersuites, id_tls_min_version, id_tls_max_version;
27
27
 
28
28
  struct trilogy_ctx {
29
29
  trilogy_conn_t conn;
@@ -140,6 +140,11 @@ static struct timeval double_to_timeval(double secs)
140
140
  };
141
141
  }
142
142
 
143
+ static double timeval_to_double(struct timeval tv)
144
+ {
145
+ return (double)tv.tv_sec + ((double)tv.tv_usec) / 1000000.0;
146
+ }
147
+
143
148
  static int _cb_ruby_wait(trilogy_sock_t *sock, trilogy_wait_t wait)
144
149
  {
145
150
  struct timeval *timeout = NULL;
@@ -606,6 +611,10 @@ static VALUE execute_read_query(VALUE vargs)
606
611
  rb_ivar_set(result, id_ivar_query_time, DBL2NUM(query_time));
607
612
 
608
613
  if (rc == TRILOGY_OK) {
614
+ rb_ivar_set(result, id_ivar_last_insert_id, ULL2NUM(ctx->conn.last_insert_id));
615
+
616
+ rb_ivar_set(result, id_ivar_affected_rows, ULL2NUM(ctx->conn.affected_rows));
617
+
609
618
  return result;
610
619
  }
611
620
 
@@ -631,8 +640,12 @@ static VALUE execute_read_query(VALUE vargs)
631
640
  }
632
641
  }
633
642
 
643
+ #ifdef HAVE_RB_INTERNED_STR
644
+ VALUE column_name = rb_interned_str(column.name, column.name_len);
645
+ #else
634
646
  VALUE column_name = rb_str_new(column.name, column.name_len);
635
647
  OBJ_FREEZE(column_name);
648
+ #endif
636
649
 
637
650
  rb_ary_push(column_names, column_name);
638
651
 
@@ -836,6 +849,38 @@ static VALUE rb_trilogy_query_flags_set(VALUE self, VALUE query_flags)
836
849
  return get_ctx(self)->query_flags = NUM2UINT(query_flags);
837
850
  }
838
851
 
852
+ static VALUE rb_trilogy_read_timeout(VALUE self) {
853
+ struct trilogy_ctx *ctx = get_open_ctx(self);
854
+ return DBL2NUM(timeval_to_double(ctx->conn.socket->opts.read_timeout));
855
+ }
856
+
857
+ static VALUE rb_trilogy_read_timeout_set(VALUE self, VALUE read_timeout)
858
+ {
859
+ struct trilogy_ctx *ctx = get_open_ctx(self);
860
+ if (read_timeout == Qnil) {
861
+ ctx->conn.socket->opts.read_timeout = double_to_timeval(0.0);
862
+ } else {
863
+ ctx->conn.socket->opts.read_timeout = double_to_timeval(NUM2DBL(read_timeout));
864
+ }
865
+ return read_timeout;
866
+ }
867
+
868
+ static VALUE rb_trilogy_write_timeout(VALUE self) {
869
+ struct trilogy_ctx *ctx = get_open_ctx(self);
870
+ return DBL2NUM(timeval_to_double(ctx->conn.socket->opts.write_timeout));
871
+ }
872
+
873
+ static VALUE rb_trilogy_write_timeout_set(VALUE self, VALUE write_timeout)
874
+ {
875
+ struct trilogy_ctx *ctx = get_open_ctx(self);
876
+ if (write_timeout == Qnil) {
877
+ ctx->conn.socket->opts.write_timeout = double_to_timeval(0.0);
878
+ } else {
879
+ ctx->conn.socket->opts.write_timeout = double_to_timeval(NUM2DBL(write_timeout));
880
+ }
881
+ return write_timeout;
882
+ }
883
+
839
884
  static VALUE rb_trilogy_server_status(VALUE self) { return LONG2FIX(get_open_ctx(self)->conn.server_status); }
840
885
 
841
886
  static VALUE rb_trilogy_server_version(VALUE self) { return rb_str_new_cstr(get_open_ctx(self)->server_version); }
@@ -858,6 +903,10 @@ void Init_cext()
858
903
  rb_define_method(Trilogy, "last_gtid", rb_trilogy_last_gtid, 0);
859
904
  rb_define_method(Trilogy, "query_flags", rb_trilogy_query_flags, 0);
860
905
  rb_define_method(Trilogy, "query_flags=", rb_trilogy_query_flags_set, 1);
906
+ rb_define_method(Trilogy, "read_timeout", rb_trilogy_read_timeout, 0);
907
+ rb_define_method(Trilogy, "read_timeout=", rb_trilogy_read_timeout_set, 1);
908
+ rb_define_method(Trilogy, "write_timeout", rb_trilogy_write_timeout, 0);
909
+ rb_define_method(Trilogy, "write_timeout=", rb_trilogy_write_timeout_set, 1);
861
910
  rb_define_method(Trilogy, "server_status", rb_trilogy_server_status, 0);
862
911
  rb_define_method(Trilogy, "server_version", rb_trilogy_server_version, 0);
863
912
  rb_define_const(Trilogy, "TLS_VERSION_10", INT2NUM(TRILOGY_TLS_VERSION_10));
@@ -890,7 +939,9 @@ void Init_cext()
890
939
  Trilogy_Result = rb_define_class_under(Trilogy, "Result", rb_cObject);
891
940
  rb_global_variable(&Trilogy_Result);
892
941
 
942
+ rb_define_attr(Trilogy_Result, "affected_rows", 1, 0);
893
943
  rb_define_attr(Trilogy_Result, "fields", 1, 0);
944
+ rb_define_attr(Trilogy_Result, "last_insert_id", 1, 0);
894
945
  rb_define_attr(Trilogy_Result, "rows", 1, 0);
895
946
  rb_define_attr(Trilogy_Result, "query_time", 1, 0);
896
947
 
@@ -920,14 +971,16 @@ void Init_cext()
920
971
  id_tls_min_version = rb_intern("tls_min_version");
921
972
  id_tls_max_version = rb_intern("tls_max_version");
922
973
 
974
+ id_ivar_affected_rows = rb_intern("@affected_rows");
923
975
  id_ivar_fields = rb_intern("@fields");
976
+ id_ivar_last_insert_id = rb_intern("@last_insert_id");
924
977
  id_ivar_rows = rb_intern("@rows");
925
978
  id_ivar_query_time = rb_intern("@query_time");
926
979
 
927
980
  rb_trilogy_cast_init();
928
981
 
929
982
  // server_status flags
930
- #define XX(name, code) rb_const_set(Trilogy, rb_intern(#name + strlen("TRILOGY_")), LONG2NUM(name));
983
+ #define XX(name, code) rb_const_set(Trilogy, rb_intern((char *)#name + strlen("TRILOGY_")), LONG2NUM(name));
931
984
  TRILOGY_SERVER_STATUS(XX)
932
985
  #undef XX
933
986
  }
@@ -12,5 +12,6 @@ dir_config("openssl")
12
12
 
13
13
  have_library("crypto", "CRYPTO_malloc")
14
14
  have_library("ssl", "SSL_new")
15
+ have_func("rb_interned_str", "ruby.h")
15
16
 
16
17
  create_makefile "trilogy/cext"
@@ -307,7 +307,7 @@ fail:
307
307
  static ssize_t ssl_io_return(struct trilogy_sock *sock, ssize_t ret)
308
308
  {
309
309
  if (ret < 0) {
310
- int rc = SSL_get_error(sock->ssl, ret);
310
+ int rc = SSL_get_error(sock->ssl, (int)ret);
311
311
  if (rc == SSL_ERROR_WANT_WRITE || rc == SSL_ERROR_WANT_READ) {
312
312
  return (ssize_t)TRILOGY_AGAIN;
313
313
  } else if (rc == SSL_ERROR_SYSCALL && errno != 0) {
@@ -375,7 +375,7 @@ static int trilogy_tls_version_map[] = {0, TLS1_VERSION, TLS1_1_VERSION, TLS1_2_
375
375
  #endif
376
376
  };
377
377
 
378
- int trilogy_set_min_proto_version(SSL_CTX *ctx, trilogy_tls_version_t version)
378
+ long trilogy_set_min_proto_version(SSL_CTX *ctx, trilogy_tls_version_t version)
379
379
  {
380
380
  int ssl_ver = trilogy_tls_version_map[version];
381
381
  if (ssl_ver == 0) {
@@ -385,7 +385,7 @@ int trilogy_set_min_proto_version(SSL_CTX *ctx, trilogy_tls_version_t version)
385
385
  return SSL_CTX_set_min_proto_version(ctx, ssl_ver);
386
386
  }
387
387
 
388
- int trilogy_set_max_proto_version(SSL_CTX *ctx, trilogy_tls_version_t version)
388
+ long trilogy_set_max_proto_version(SSL_CTX *ctx, trilogy_tls_version_t version)
389
389
  {
390
390
  int ssl_ver = trilogy_tls_version_map[version];
391
391
  if (ssl_ver == 0) {
@@ -1,3 +1,3 @@
1
1
  class Trilogy
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trilogy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-15 00:00:00.000000000 Z
11
+ date: 2022-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
101
  requirements: []
102
- rubygems_version: 3.3.0.dev
102
+ rubygems_version: 3.3.3
103
103
  signing_key:
104
104
  specification_version: 4
105
105
  summary: A friendly MySQL-compatible library for Ruby, binding to libtrilogy