|
13 | 13 | #include "duckdb/main/extension_util.hpp" |
14 | 14 | #include "duckdb/parser/parsed_data/create_type_info.hpp" |
15 | 15 | #include "functions.hpp" |
| 16 | +#include "holders.hpp" |
16 | 17 | #include "refs.hpp" |
17 | 18 | #include "types.hpp" |
18 | 19 | #include "util.hpp" |
@@ -59,40 +60,6 @@ JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) { |
59 | 60 | delete_global_refs(env); |
60 | 61 | } |
61 | 62 |
|
62 | | -/** |
63 | | - * Associates a duckdb::Connection with a duckdb::DuckDB. The DB may be shared amongst many ConnectionHolders, but the |
64 | | - * Connection is unique to this holder. Every Java DuckDBConnection has exactly 1 of these holders, and they are never |
65 | | - * shared. The holder is freed when the DuckDBConnection is closed. When the last holder sharing a DuckDB is freed, the |
66 | | - * DuckDB is released as well. |
67 | | - */ |
68 | | -struct ConnectionHolder { |
69 | | - const duckdb::shared_ptr<duckdb::DuckDB> db; |
70 | | - const duckdb::unique_ptr<duckdb::Connection> connection; |
71 | | - |
72 | | - ConnectionHolder(duckdb::shared_ptr<duckdb::DuckDB> _db) |
73 | | - : db(_db), connection(make_uniq<duckdb::Connection>(*_db)) { |
74 | | - } |
75 | | -}; |
76 | | - |
77 | | -/** |
78 | | - * Throws a SQLException and returns nullptr if a valid Connection can't be retrieved from the buffer. |
79 | | - */ |
80 | | -static Connection *get_connection(JNIEnv *env, jobject conn_ref_buf) { |
81 | | - if (!conn_ref_buf) { |
82 | | - throw ConnectionException("Invalid connection"); |
83 | | - } |
84 | | - auto conn_holder = (ConnectionHolder *)env->GetDirectBufferAddress(conn_ref_buf); |
85 | | - if (!conn_holder) { |
86 | | - throw ConnectionException("Invalid connection"); |
87 | | - } |
88 | | - auto conn_ref = conn_holder->connection.get(); |
89 | | - if (!conn_ref || !conn_ref->context) { |
90 | | - throw ConnectionException("Invalid connection"); |
91 | | - } |
92 | | - |
93 | | - return conn_ref; |
94 | | -} |
95 | | - |
96 | 63 | //! The database instance cache, used so that multiple connections to the same file point to the same database object |
97 | 64 | duckdb::DBInstanceCache instance_cache; |
98 | 65 |
|
@@ -189,10 +156,6 @@ void _duckdb_jdbc_disconnect(JNIEnv *env, jclass, jobject conn_ref_buf) { |
189 | 156 | } |
190 | 157 | } |
191 | 158 |
|
192 | | -struct StatementHolder { |
193 | | - duckdb::unique_ptr<PreparedStatement> stmt; |
194 | | -}; |
195 | | - |
196 | 159 | #include "utf8proc_wrapper.hpp" |
197 | 160 |
|
198 | 161 | jobject _duckdb_jdbc_prepare(JNIEnv *env, jclass, jobject conn_ref_buf, jbyteArray query_j) { |
@@ -233,11 +196,6 @@ jobject _duckdb_jdbc_prepare(JNIEnv *env, jclass, jobject conn_ref_buf, jbyteArr |
233 | 196 | return env->NewDirectByteBuffer(stmt_ref, 0); |
234 | 197 | } |
235 | 198 |
|
236 | | -struct ResultHolder { |
237 | | - duckdb::unique_ptr<QueryResult> res; |
238 | | - duckdb::unique_ptr<DataChunk> chunk; |
239 | | -}; |
240 | | - |
241 | 199 | Value ToValue(JNIEnv *env, jobject param, duckdb::shared_ptr<ClientContext> context) { |
242 | 200 | param = env->CallStaticObjectMethod(J_Timestamp, J_Timestamp_valueOf, param); |
243 | 201 |
|
|
0 commit comments