duckdb 1.5.6.0 → 1.5.6.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: cd491bbe1e80d7e2f20455e768b0331c91cbd015e570ccc023497c74217f86a0
4
- data.tar.gz: b3c9d5bd5b38a7f72fa7d8c00be7bd20d61505c234efc702cd365b040dcce0dd
3
+ metadata.gz: 74ccac3599175a19bbc80ef6e9ad8e9aae62152d96b78dd6357623f647b62ff2
4
+ data.tar.gz: 9302451535c8b0b32f561a7deb45bd0f1800a77889592308c5e94714abd5fa33
5
5
  SHA512:
6
- metadata.gz: acc1eb730e31250b6d8cc281923dd332b2141a4fb2ced34821126928b0c94757a6b1c5f49e29c39c01e899b196e4fe857ea529d62bd8fd88015c2dad806fbb8f
7
- data.tar.gz: a18fc12e5e6252c32129d8ab005f75b29834711fc5790e009a8dc45fabcb9c9c9e88f1c16213a16bf346da906087ec9f57dea7e6162e51554d622a20575cdf55
6
+ metadata.gz: 29981f3882568513062d0a59e04e434dd8b557635c70b51fb2bfc017a077bf7076a10b384b676a7c32e7bf0d6d24420622e4e04164fced341b9165fe11cce062
7
+ data.tar.gz: e16e3171bd0c0f8f0e26f2c48e6f3a4d73fb1c93b00a01a4ae5d790a66ea0a198aa722d91790eb95e3b4fb1f66e167e3a69cf0377effa39138e801d7eb9eac16
data/CHANGELOG.md CHANGED
@@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  # Unreleased
6
6
 
7
+ # 1.5.6.1 - 2026-10-17
8
+ - fix `DuckDB::ExtractedStatements.new`, `Connection#query` and `Connection#extract` raising `Failed to extract statements(Database connection closed?).` for SQL that contains no statements, such as only a comment, whitespace or `;` (issue #1490). `ExtractedStatements#size` is now `0`, `Connection#query` returns `nil` and `Connection#extract` returns `[]`. Calling `ExtractedStatements.new` on a closed connection now raises `Database connection closed`.
9
+
7
10
  # 1.5.6.0 - 2026-10-11
8
11
  - bump up DuckDB 1.5.6 on CI.
9
12
 
@@ -75,6 +75,15 @@ rubyDuckDBConnection *rbduckdb_get_struct_connection(VALUE obj) {
75
75
  return ctx;
76
76
  }
77
77
 
78
+ rubyDuckDBConnection *rbduckdb_get_open_struct_connection(VALUE obj) {
79
+ rubyDuckDBConnection *ctx = rbduckdb_get_struct_connection(obj);
80
+
81
+ if (!(ctx->con)) {
82
+ rb_raise(eDuckDBError, "Database connection closed");
83
+ }
84
+ return ctx;
85
+ }
86
+
78
87
  VALUE rbduckdb_create_connection(VALUE oDuckDBDatabase) {
79
88
  rubyDuckDB *ctxdb;
80
89
  rubyDuckDBConnection *ctxcon;
@@ -203,13 +212,9 @@ static VALUE connection__query_sql(VALUE self, VALUE str) {
203
212
 
204
213
  VALUE result = rbduckdb_create_result();
205
214
 
206
- TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
215
+ ctx = rbduckdb_get_open_struct_connection(self);
207
216
  ctxr = rbduckdb_get_struct_result(result);
208
217
 
209
- if (!(ctx->con)) {
210
- rb_raise(eDuckDBError, "Database connection closed");
211
- }
212
-
213
218
  /* Extract C string before releasing GVL (StringValueCStr is a Ruby operation) */
214
219
  const char *sql = StringValueCStr(str);
215
220
 
@@ -235,11 +240,7 @@ static VALUE connection__get_table_names(VALUE self, VALUE query, VALUE qualifie
235
240
  rubyDuckDBConnection *ctx;
236
241
  duckdb_value table_names;
237
242
 
238
- ctx = rbduckdb_get_struct_connection(self);
239
-
240
- if (!(ctx->con)) {
241
- rb_raise(eDuckDBError, "Database connection closed");
242
- }
243
+ ctx = rbduckdb_get_open_struct_connection(self);
243
244
 
244
245
  table_names = duckdb_get_table_names(ctx->con, StringValueCStr(query), RTEST(qualified));
245
246
 
@@ -10,6 +10,7 @@ struct _rubyDuckDBConnection {
10
10
  typedef struct _rubyDuckDBConnection rubyDuckDBConnection;
11
11
 
12
12
  rubyDuckDBConnection *rbduckdb_get_struct_connection(VALUE obj);
13
+ rubyDuckDBConnection *rbduckdb_get_open_struct_connection(VALUE obj);
13
14
  void rbduckdb_init_connection(void);
14
15
  VALUE rbduckdb_create_connection(VALUE oDuckDBDatabase);
15
16
 
@@ -50,14 +50,19 @@ static VALUE extracted_statements__initialize(VALUE self, VALUE con, VALUE query
50
50
  }
51
51
 
52
52
  pquery = StringValuePtr(query);
53
- pcon = rbduckdb_get_struct_connection(con);
53
+ pcon = rbduckdb_get_open_struct_connection(con);
54
54
  TypedData_Get_Struct(self, rubyDuckDBExtractedStatements, &extract_statements_data_type, ctx);
55
55
 
56
56
  ctx->num_statements = duckdb_extract_statements(pcon->con, pquery, &(ctx->extracted_statements));
57
57
 
58
- if (ctx->num_statements == 0) {
59
- error = duckdb_extract_statements_error(ctx->extracted_statements);
60
- rb_raise(eDuckDBError, "%s", error ? error : "Failed to extract statements(Database connection closed?).");
58
+ /*
59
+ * duckdb_extract_statements returns 0 both on a parse error and when the
60
+ * query contains no statements (e.g. only a comment). Only the former
61
+ * sets an error message.
62
+ */
63
+ error = duckdb_extract_statements_error(ctx->extracted_statements);
64
+ if (error) {
65
+ rb_raise(eDuckDBError, "%s", error);
61
66
  }
62
67
 
63
68
  return self;
@@ -3,5 +3,5 @@
3
3
  module DuckDB
4
4
  # The version string of ruby-duckdb.
5
5
  # Currently, ruby-duckdb is NOT semantic versioning.
6
- VERSION = '1.5.6.0'
6
+ VERSION = '1.5.6.1'
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duckdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.6.0
4
+ version: 1.5.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Suketa