sequel_pg 1.14.0 → 1.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 277c659f136e9d34a715ccd94bab948b776d903f72b0f679fd919bedacef9cf7
4
- data.tar.gz: 031cd967776330ecc1c999c8597c49eb5a96f376dfcc88c51ab9d9bdbda52190
3
+ metadata.gz: 41aa757cb6f4ca6f56ca26044517a47a68731dd7d51335451f6da2e5b5b34d6f
4
+ data.tar.gz: ec43d49fd7b4b8821ecbb813f6244aaf46f69866e84b94df96a3c52ef3a6fd41
5
5
  SHA512:
6
- metadata.gz: 7b722922bf49095005ad19bc7bb1ba41d358d851f367df6f51bd5fbf0202784244cee83293919ee27fb1ff7accb3fb10ddbbc7745455cf545f2b1a7a7e301bdd
7
- data.tar.gz: 2b3933ab84065cdd81b5c544523ba4c50192acbc912b449d4d4f03d5650873a5ad125fc3f339a435cbcc514d350bbf6e98d49d10f39349faa9cb8b2c7236fa61
6
+ metadata.gz: 2a2578bec8fed224dcd3c1263cb86a4729cf11318f80d6cdb03366ae7dae6e68995447db06a1105d1ecda50222d2ff6258079fb7395d3f262094e1e05502fd48
7
+ data.tar.gz: 26a470d0e7d8290cade76b07cecd972be840c838492607a5649c0fd803de2ca7ea2e34b0c77fddcaff734a2a875b1f26ce8d5b03ec0fe0ab887ae3045ffa10e0
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ === 1.15.0 (2022-03-16)
2
+
3
+ * Avoid deprecation warning in the pg_streaming extension on pg 1.3+ when streaming a query with bound parameters (jeremyevans)
4
+
5
+ * Use pgresult_stream_any when using pg 1.3.4+ for faster streaming (jeremyevans)
6
+
7
+ * Do not use streaming by default for Dataset#paged_each in the pg_streaming extension (jeremyevans)
8
+
9
+ * Avoid verbose warning if loading sequel_pg after Sequel pg_array extension (jeremyevans)
10
+
1
11
  === 1.14.0 (2020-09-22)
2
12
 
3
13
  * Reduce stack memory usage for result sets with 64 or fewer columns (jeremyevans)
data/README.rdoc CHANGED
@@ -112,20 +112,6 @@ requirements:
112
112
 
113
113
  rake build
114
114
 
115
- == Platforms Supported
116
-
117
- sequel_pg has been tested on the following:
118
-
119
- * ruby 1.9.3
120
- * ruby 2.0
121
- * ruby 2.1
122
- * ruby 2.2
123
- * ruby 2.3
124
- * ruby 2.4
125
- * ruby 2.5
126
- * ruby 2.6
127
- * ruby 2.7
128
-
129
115
  == Known Issues
130
116
 
131
117
  * You must be using the ISO PostgreSQL date format (which is the
@@ -1,4 +1,4 @@
1
- #define SEQUEL_PG_VERSION_INTEGER 11400
1
+ #define SEQUEL_PG_VERSION_INTEGER 11500
2
2
 
3
3
  #include <string.h>
4
4
  #include <stdio.h>
@@ -70,9 +70,11 @@
70
70
  PGconn* pg_get_pgconn(VALUE);
71
71
  PGresult* pgresult_get(VALUE);
72
72
  int pg_get_result_enc_idx(VALUE);
73
+ VALUE pgresult_stream_any(VALUE self, void (*yielder)(VALUE, int, int, void*), void* data);
73
74
 
74
75
  static int spg_use_ipaddr_alloc;
75
76
  static int spg_use_pg_get_result_enc_idx;
77
+ static int spg_use_pg_stream_any;
76
78
 
77
79
  static VALUE spg_Sequel;
78
80
  static VALUE spg_PGArray;
@@ -532,7 +534,7 @@ static VALUE spg_timestamp(const char *s, VALUE self, size_t length, int tz) {
532
534
  }
533
535
 
534
536
  if (remaining < 19) {
535
- return spg_timestamp_error(s, self, "unexpected timetamp format, too short");
537
+ return spg_timestamp_error(s, self, "unexpected timestamp format, too short");
536
538
  }
537
539
 
538
540
  year = parse_year(&p, &remaining);
@@ -1659,6 +1661,38 @@ static VALUE spg_set_single_row_mode(VALUE self) {
1659
1661
  return Qnil;
1660
1662
  }
1661
1663
 
1664
+ struct spg__yield_each_row_stream_data {
1665
+ VALUE self;
1666
+ VALUE *colsyms;
1667
+ VALUE *colconvert;
1668
+ VALUE pg_value;
1669
+ int enc_index;
1670
+ char type;
1671
+ };
1672
+
1673
+ static void spg__yield_each_row_stream(VALUE rres, int ntuples, int nfields, void *rdata) {
1674
+ struct spg__yield_each_row_stream_data* data = (struct spg__yield_each_row_stream_data *)rdata;
1675
+ VALUE h = rb_hash_new();
1676
+ VALUE self = data->self;
1677
+ VALUE *colsyms = data->colsyms;
1678
+ VALUE *colconvert= data->colconvert;
1679
+ PGresult *res = pgresult_get(rres);
1680
+ int enc_index = data->enc_index;
1681
+ long j;
1682
+
1683
+ for(j=0; j<nfields; j++) {
1684
+ rb_hash_aset(h, colsyms[j], spg__col_value(self, res, 0, j, colconvert , enc_index));
1685
+ }
1686
+
1687
+ if(data->type == SPG_YIELD_MODEL) {
1688
+ VALUE model = rb_obj_alloc(data->pg_value);
1689
+ rb_ivar_set(model, spg_id_values, h);
1690
+ rb_yield(model);
1691
+ } else {
1692
+ rb_yield(h);
1693
+ }
1694
+ }
1695
+
1662
1696
  static VALUE spg__yield_each_row_internal(VALUE self, VALUE rconn, VALUE rres, PGresult *res, int enc_index, VALUE *colsyms, VALUE *colconvert) {
1663
1697
  long nfields;
1664
1698
  long j;
@@ -1667,6 +1701,7 @@ static VALUE spg__yield_each_row_internal(VALUE self, VALUE rconn, VALUE rres, P
1667
1701
  VALUE pg_type;
1668
1702
  VALUE pg_value = Qnil;
1669
1703
  char type = SPG_YIELD_NORMAL;
1704
+ struct spg__yield_each_row_stream_data data;
1670
1705
 
1671
1706
  nfields = PQnfields(res);
1672
1707
 
@@ -1684,6 +1719,18 @@ static VALUE spg__yield_each_row_internal(VALUE self, VALUE rconn, VALUE rres, P
1684
1719
 
1685
1720
  spg_set_column_info(self, res, colsyms, colconvert, enc_index);
1686
1721
 
1722
+ if (spg_use_pg_stream_any) {
1723
+ data.self = self;
1724
+ data.colsyms = colsyms;
1725
+ data.colconvert = colconvert;
1726
+ data.pg_value = pg_value;
1727
+ data.enc_index = enc_index;
1728
+ data.type = type;
1729
+
1730
+ pgresult_stream_any(rres, spg__yield_each_row_stream, &data);
1731
+ return self;
1732
+ }
1733
+
1687
1734
  while (PQntuples(res) != 0) {
1688
1735
  h = rb_hash_new();
1689
1736
  for(j=0; j<nfields; j++) {
@@ -1809,10 +1856,21 @@ void Init_sequel_pg(void) {
1809
1856
  }
1810
1857
  }
1811
1858
 
1812
- if (RTEST(rb_eval_string("defined?(PG::VERSION) && PG::VERSION.to_f >= 1.2"))) {
1813
- spg_use_pg_get_result_enc_idx = 1;
1859
+ c = rb_eval_string("defined?(PG::VERSION) && PG::VERSION.split('.').map(&:to_i)");
1860
+ if (RB_TYPE_P(c, T_ARRAY) && RARRAY_LEN(c) >= 3) {
1861
+ if (FIX2INT(RARRAY_AREF(c, 0)) > 1) {
1862
+ spg_use_pg_get_result_enc_idx = 1;
1863
+ spg_use_pg_stream_any = 1;
1864
+ } else if (FIX2INT(RARRAY_AREF(c, 0)) == 1) {
1865
+ if (FIX2INT(RARRAY_AREF(c, 1)) >= 2) {
1866
+ spg_use_pg_get_result_enc_idx = 1;
1867
+ }
1868
+ if (FIX2INT(RARRAY_AREF(c, 1)) > 3 || (FIX2INT(RARRAY_AREF(c, 1)) == 3 && FIX2INT(RARRAY_AREF(c, 2)) >= 4)) {
1869
+ spg_use_pg_stream_any = 1;
1870
+ }
1871
+ }
1814
1872
  }
1815
-
1873
+
1816
1874
  rb_const_set(spg_Postgres, rb_intern("SEQUEL_PG_VERSION_INTEGER"), INT2FIX(SEQUEL_PG_VERSION_INTEGER));
1817
1875
 
1818
1876
  spg_id_BigDecimal = rb_intern("BigDecimal");
@@ -73,12 +73,18 @@ module Sequel::Postgres::Streaming
73
73
 
74
74
  private
75
75
 
76
+ unless Sequel::Postgres::Adapter.method_defined?(:send_query_params)
77
+ def send_query_params(*args)
78
+ send_query(*args)
79
+ end
80
+ end
81
+
76
82
  if Sequel::Database.instance_methods.map(&:to_s).include?('log_connection_yield')
77
83
  # If using single row mode, send the query instead of executing it.
78
84
  def execute_query(sql, args)
79
85
  if @single_row_mode
80
86
  @single_row_mode = false
81
- @db.log_connection_yield(sql, self, args){args ? send_query(sql, args) : send_query(sql)}
87
+ @db.log_connection_yield(sql, self, args){args ? send_query_params(sql, args) : send_query(sql)}
82
88
  set_single_row_mode
83
89
  block
84
90
  self
@@ -122,7 +128,12 @@ module Sequel::Postgres::Streaming
122
128
  unless block_given?
123
129
  return enum_for(:paged_each, opts)
124
130
  end
125
- stream.each(&block)
131
+
132
+ if stream_results?
133
+ each(&block)
134
+ else
135
+ super
136
+ end
126
137
  end
127
138
 
128
139
  # Return a clone of the dataset that will use streaming to load
@@ -120,6 +120,9 @@ if defined?(Sequel::Postgres::PGArray)
120
120
  # pg_array extension previously loaded
121
121
 
122
122
  class Sequel::Postgres::PGArray::Creator
123
+ # Avoid method redefined verbose warning
124
+ alias call call if method_defined?(:call)
125
+
123
126
  # Override Creator to use sequel_pg's C-based parser instead of the pure ruby parser.
124
127
  def call(string)
125
128
  Sequel::Postgres::PGArray.new(Sequel::Postgres.parse_pg_array(string, @converter), @type)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  requirements: []
104
- rubygems_version: 3.1.2
104
+ rubygems_version: 3.3.7
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Faster SELECTs when using Sequel with pg