You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ko...@apache.org on 2023/04/15 14:08:06 UTC
[arrow-adbc] branch main updated: feat(glib): add gadbc_connection_set_read_only() (#589)
This is an automated email from the ASF dual-hosted git repository.
kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 31668dd feat(glib): add gadbc_connection_set_read_only() (#589)
31668dd is described below
commit 31668ddcfe8610020ce2d7794782bd689019fc69
Author: Sutou Kouhei <ko...@clear-code.com>
AuthorDate: Sat Apr 15 23:08:00 2023 +0900
feat(glib): add gadbc_connection_set_read_only() (#589)
Fixes #552.
---
glib/adbc-glib/connection.c | 16 ++++++++++++++++
glib/adbc-glib/connection.h | 3 +++
glib/test/test-connection.rb | 12 ++++++++++++
3 files changed, 31 insertions(+)
diff --git a/glib/adbc-glib/connection.c b/glib/adbc-glib/connection.c
index ade4007..a5ffda3 100644
--- a/glib/adbc-glib/connection.c
+++ b/glib/adbc-glib/connection.c
@@ -166,6 +166,22 @@ gboolean gadbc_connection_set_auto_commit(GADBCConnection* connection,
BOOLEAN_TO_OPTION_VALUE(auto_commit), error);
}
+/**
+ * gadbc_connection_set_read_only:
+ * @connection: A #GADBCConnection.
+ * @read_only: Whether read only or not.
+ * @error: (nullable): Return location for a #GError or %NULL.
+ *
+ * Returns: %TRUE if this is set successfully, %FALSE otherwise.
+ *
+ * Since: 0.4.0
+ */
+gboolean gadbc_connection_set_read_only(GADBCConnection* connection, gboolean read_only,
+ GError** error) {
+ return gadbc_connection_set_option(connection, ADBC_CONNECTION_OPTION_READ_ONLY,
+ BOOLEAN_TO_OPTION_VALUE(read_only), error);
+}
+
/**
* gadbc_connection_init:
* @connection: A #GADBCConnection.
diff --git a/glib/adbc-glib/connection.h b/glib/adbc-glib/connection.h
index 971321c..515a958 100644
--- a/glib/adbc-glib/connection.h
+++ b/glib/adbc-glib/connection.h
@@ -67,6 +67,9 @@ gboolean gadbc_connection_set_option(GADBCConnection* connection, const gchar* k
GADBC_AVAILABLE_IN_0_4
gboolean gadbc_connection_set_auto_commit(GADBCConnection* connection,
gboolean auto_commit, GError** error);
+GADBC_AVAILABLE_IN_0_4
+gboolean gadbc_connection_set_read_only(GADBCConnection* connection, gboolean read_only,
+ GError** error);
GADBC_AVAILABLE_IN_0_1
gboolean gadbc_connection_init(GADBCConnection* connection, GADBCDatabase* database,
GError** error);
diff --git a/glib/test/test-connection.rb b/glib/test/test-connection.rb
index 9ed3692..c559c1a 100644
--- a/glib/test/test-connection.rb
+++ b/glib/test/test-connection.rb
@@ -134,6 +134,18 @@ class ConnectionTest < Test::Unit::TestCase
end
end
+ def test_read_only
+ open_connection do |connection|
+ message =
+ "[adbc][connection][set-option]" +
+ "[ADBC_STATUS_NOT_IMPLEMENTED (2)][0] " +
+ "[SQLite] Unknown connection option adbc.connection.readonly=false"
+ assert_raise(ADBC::Error::NotImplemented.new(message)) do
+ connection.read_only = false
+ end
+ end
+ end
+
def test_commit
open_connection do |connection|
execute_sql(connection,