sequel_pg 1.18.2 → 1.19.0

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: 371cfb0adb516e68f44ec7ca7f984b382afb2326da27f5f28529763f97de4639
4
- data.tar.gz: 9840a973b0177c38c729d2fa18adfb2ceb27ab46415acc0af44bb030ebd88789
3
+ metadata.gz: 8ce323f82d06024c56ba214fa69c6e63e243c29370b530eda09865d9eebd8ad1
4
+ data.tar.gz: 2719034e2a533d328ffe3a2e73834c0074c5f9efc6053d4865c58e136eee5554
5
5
  SHA512:
6
- metadata.gz: e42329a94078d6321715169e11935083d48f6e931662c48cb118003d5039adc95385b8ef4a12e20c095d0253cd1ccd6f413f7e0fcece885584dfb78927350efa
7
- data.tar.gz: 2735511f3a2d456abdc196ea7db8a7c1fdb74f1648d004b00b794a7b7d1cc39186fa9db02a1d92aac3a962eb7208ec7a96aa432eeb82a8609e310add3ebf0613
6
+ metadata.gz: 4dcf359f0300e00c3249a3caaea255d18dff3770a1e6bfb51e6ac96dee7809a31680f093fb476457fea4b67ccf457355d5295b369c725d2b142773bd21171aa9
7
+ data.tar.gz: 32275e2f6cbc631f513606b053d8c6660d497a76cc926dd8af7314f2ebad0c17f5b72db1a02d0267f4e265070a3874921e2a4b3a8bfe9f40467728e5a62a25d9
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.19.0 (2026-03-06)
2
+
3
+ * Cancel the query if an exception is raised while streaming query results (jtmkrueger, jeremyevans) (#66)
4
+
1
5
  === 1.18.2 (2025-12-18)
2
6
 
3
7
  * Avoid bogus warnings about the implicit block parameter in Ruby 3.3 (jeremyevans) (#64)
@@ -10,6 +10,7 @@ if (have_library('pq') || have_library('libpq') || have_library('ms/libpq')) &&
10
10
  have_func 'rb_hash_new_capa'
11
11
  have_func 'rb_set_new_capa'
12
12
  have_func 'PQsetSingleRowMode'
13
+ have_func 'PQcancelCreate'
13
14
  have_func 'timegm'
14
15
  create_makefile("sequel_pg")
15
16
  else
@@ -1,4 +1,4 @@
1
- #define SEQUEL_PG_VERSION_INTEGER 11802
1
+ #define SEQUEL_PG_VERSION_INTEGER 11900
2
2
 
3
3
  #include <string.h>
4
4
  #include <stdio.h>
@@ -2004,6 +2004,38 @@ static VALUE spg__flush_results(VALUE rconn) {
2004
2004
  VALUE error = 0;
2005
2005
  conn = pg_get_pgconn(rconn);
2006
2006
 
2007
+ /* Only cancel if an exception is being unwound. During normal
2008
+ * completion, the query has already finished and there are no
2009
+ * results to drain, so canceling is unnecessary. */
2010
+ if (rb_errinfo() != Qnil) {
2011
+ #ifdef HAVE_PQCANCELCREATE
2012
+ PGcancelConn *cancel = PQcancelCreate(conn);
2013
+ if (cancel) {
2014
+ int cancel_ok = PQcancelBlocking(cancel);
2015
+ PQcancelFinish(cancel);
2016
+ #else
2017
+ PGcancel *cancel = PQgetCancel(conn);
2018
+ if (cancel) {
2019
+ char errbuf[256];
2020
+ int cancel_ok = PQcancel(cancel, errbuf, sizeof(errbuf));
2021
+ PQfreeCancel(cancel);
2022
+ #endif
2023
+
2024
+ if (cancel_ok) {
2025
+ /* Cancel succeeded. Drain remaining results without raising.
2026
+ * The cancel produces an expected error result ("canceling
2027
+ * statement due to user request"). The original exception
2028
+ * will propagate via rb_ensure. */
2029
+ while ((res = PQgetResult(conn)) != NULL) {
2030
+ PQclear(res);
2031
+ }
2032
+ return rconn;
2033
+ }
2034
+ /* Cancel failed. Fallthrough to the normal drain loop which
2035
+ * will check for and report any real errors. */
2036
+ }
2037
+ }
2038
+
2007
2039
  while ((res = PQgetResult(conn)) != NULL) {
2008
2040
  if (!error) {
2009
2041
  switch (PQresultStatus(res))
@@ -2019,7 +2051,7 @@ static VALUE spg__flush_results(VALUE rconn) {
2019
2051
  }
2020
2052
  PQclear(res);
2021
2053
  }
2022
-
2054
+
2023
2055
  if (error) {
2024
2056
  VALUE exception = rb_exc_new3(spg_PGError, error);
2025
2057
  rb_iv_set(exception, "@connection", rconn);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.2
4
+ version: 1.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  requirements: []
103
- rubygems_version: 3.6.9
103
+ rubygems_version: 4.0.3
104
104
  specification_version: 4
105
105
  summary: Faster SELECTs when using Sequel with pg
106
106
  test_files: []