@@ -400,7 +400,8 @@ void _duckdb_jdbc_free_result(JNIEnv *env, jclass, jobject res_ref_buf) {
400
400
}
401
401
402
402
static jobject build_meta (JNIEnv *env, size_t column_count, size_t n_param, const duckdb::vector<string> &names,
403
- const duckdb::vector<LogicalType> &types, StatementProperties properties) {
403
+ const duckdb::vector<LogicalType> &types, StatementProperties properties,
404
+ const duckdb::vector<LogicalType> ¶m_types) {
404
405
auto name_array = env->NewObjectArray (column_count, J_String, nullptr );
405
406
auto type_array = env->NewObjectArray (column_count, J_String, nullptr );
406
407
auto type_detail_array = env->NewObjectArray (column_count, J_String, nullptr );
@@ -420,10 +421,26 @@ static jobject build_meta(JNIEnv *env, size_t column_count, size_t n_param, cons
420
421
env->NewStringUTF (type_to_jduckdb_type (types[col_idx]).c_str ()));
421
422
}
422
423
424
+ auto param_type_array = env->NewObjectArray (n_param, J_String, nullptr );
425
+ auto param_type_detail_array = env->NewObjectArray (n_param, J_String, nullptr );
426
+
427
+ for (idx_t param_idx = 0 ; param_idx < n_param; param_idx++) {
428
+ std::string param_name;
429
+ if (param_types[param_idx].id () == LogicalTypeId::ENUM) {
430
+ param_name = " ENUM" ;
431
+ } else {
432
+ param_name = param_types[param_idx].ToString ();
433
+ }
434
+
435
+ env->SetObjectArrayElement (param_type_array, param_idx, env->NewStringUTF (param_name.c_str ()));
436
+ env->SetObjectArrayElement (param_type_detail_array, param_idx,
437
+ env->NewStringUTF (type_to_jduckdb_type (param_types[param_idx]).c_str ()));
438
+ }
439
+
423
440
auto return_type = env->NewStringUTF (StatementReturnTypeToString (properties.return_type ).c_str ());
424
441
425
442
return env->NewObject (J_DuckResultSetMeta, J_DuckResultSetMeta_init, n_param, column_count, name_array, type_array,
426
- type_detail_array, return_type);
443
+ type_detail_array, return_type, param_type_array, param_type_detail_array );
427
444
}
428
445
429
446
jobject _duckdb_jdbc_query_result_meta (JNIEnv *env, jclass, jobject res_ref_buf) {
@@ -433,9 +450,11 @@ jobject _duckdb_jdbc_query_result_meta(JNIEnv *env, jclass, jobject res_ref_buf)
433
450
}
434
451
auto &result = res_ref->res ;
435
452
436
- auto n_param = -1 ; // no params now
453
+ auto n_param = 0 ; // no params now
454
+ duckdb::vector<LogicalType> param_types (n_param);
437
455
438
- return build_meta (env, result->ColumnCount (), n_param, result->names , result->types , result->properties );
456
+ return build_meta (env, result->ColumnCount (), n_param, result->names , result->types , result->properties ,
457
+ param_types);
439
458
}
440
459
441
460
jobject _duckdb_jdbc_prepared_statement_meta (JNIEnv *env, jclass, jobject stmt_ref_buf) {
@@ -447,9 +466,16 @@ jobject _duckdb_jdbc_prepared_statement_meta(JNIEnv *env, jclass, jobject stmt_r
447
466
448
467
auto &stmt = stmt_ref->stmt ;
449
468
auto n_param = stmt->named_param_map .size ();
469
+ duckdb::vector<LogicalType> param_types (n_param);
470
+ if (n_param > 0 ) {
471
+ auto expected_parameter_types = stmt->GetExpectedParameterTypes ();
472
+ for (auto &it : stmt->named_param_map ) {
473
+ param_types[it.second - 1 ] = expected_parameter_types[it.first ];
474
+ }
475
+ }
450
476
451
477
return build_meta (env, stmt->ColumnCount (), n_param, stmt->GetNames (), stmt->GetTypes (),
452
- stmt->GetStatementProperties ());
478
+ stmt->GetStatementProperties (), param_types );
453
479
}
454
480
455
481
jobject ProcessVector (JNIEnv *env, Connection *conn_ref, Vector &vec, idx_t row_count);
0 commit comments