kou commented on code in PR #5108:
URL: https://github.com/apache/arrow-adbc/pull/5108#discussion_r4809773400


##########
glib/adbc-glib/connection.c:
##########
@@ -228,6 +228,59 @@ gboolean gadbc_connection_set_option(GADBCConnection* 
connection, const gchar* k
   return gadbc_error_check(error, status_code, &adbc_error, context);
 }
 
+/**
+ * gadbc_connection_get_option:
+ * @connection: A #GADBCConnection.
+ * @key: An option key.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: (nullable):
+ *   The option value or %NULL on error.
+ *
+ *   It should be freed with g_free() when no longer needed.
+ *
+ * Since: 1.14.0
+ */
+gchar* gadbc_connection_get_option(GADBCConnection* connection, const gchar* 
key,
+                                   GError** error) {
+  const gchar* context = "[adbc][connection][get-option]";
+  struct AdbcConnection* adbc_connection =
+      gadbc_connection_get_raw(connection, context, error);
+  if (!adbc_connection) {
+    return NULL;
+  }
+  gchar buffer[256];
+  size_t length = sizeof(buffer);
+  struct AdbcError adbc_error = {};
+  AdbcStatusCode status_code =
+      AdbcConnectionGetOption(adbc_connection, key, buffer, &length, 
&adbc_error);
+  if (!gadbc_error_check(error, status_code, &adbc_error, context)) {
+    return NULL;
+  }
+  if (length <= sizeof(buffer)) {
+    gchar* value = g_new(gchar, length);
+    memcpy(value, buffer, length);
+    return value;
+  }
+
+  size_t capacity = length;
+  gchar* value = g_new0(gchar, capacity);
+  adbc_error = (struct AdbcError){};

Review Comment:
   Ah, sorry. This is needless.
   
   ```suggestion
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to