You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by pa...@apache.org on 2023/11/06 14:49:07 UTC
(arrow-adbc) branch main updated: fix(r/adbcsqlite): Allow sqlite driver to link against sqlite3 that does not contain sqlite3_load_extension() (#1259)
This is an automated email from the ASF dual-hosted git repository.
paleolimbot 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 89c19c3d fix(r/adbcsqlite): Allow sqlite driver to link against sqlite3 that does not contain sqlite3_load_extension() (#1259)
89c19c3d is described below
commit 89c19c3d1b27970dad4813f5dbcae87fa081a3c3
Author: Dewey Dunnington <de...@voltrondata.com>
AuthorDate: Mon Nov 6 10:49:01 2023 -0400
fix(r/adbcsqlite): Allow sqlite driver to link against sqlite3 that does not contain sqlite3_load_extension() (#1259)
Closes #1255.
---
c/driver/sqlite/sqlite.c | 7 +++++++
r/adbcsqlite/configure | 13 +++++++++++++
r/adbcsqlite/tools/test_extension.c | 21 +++++++++++++++++++++
3 files changed, 41 insertions(+)
diff --git a/c/driver/sqlite/sqlite.c b/c/driver/sqlite/sqlite.c
index a6ca3f81..b388ccf1 100644
--- a/c/driver/sqlite/sqlite.c
+++ b/c/driver/sqlite/sqlite.c
@@ -297,6 +297,7 @@ AdbcStatusCode SqliteConnectionSetOption(struct AdbcConnection* connection,
conn->extension_path = strdup(value);
return ADBC_STATUS_OK;
} else if (strcmp(key, kConnectionOptionLoadExtensionEntrypoint) == 0) {
+#if !defined(ADBC_SQLITE_WITH_NO_LOAD_EXTENSION)
if (!conn->conn) {
SetError(error, "[SQLite] %s can only be set after AdbcConnectionInit", key);
return ADBC_STATUS_INVALID_STATE;
@@ -320,6 +321,12 @@ AdbcStatusCode SqliteConnectionSetOption(struct AdbcConnection* connection,
free(conn->extension_path);
conn->extension_path = NULL;
return ADBC_STATUS_OK;
+#else
+ SetError(error,
+ "[SQLite] This build of the ADBC SQLite driver does not support extension "
+ "loading");
+ return ADBC_STATUS_NOT_IMPLEMENTED;
+#endif
}
SetError(error, "[SQLite] Unknown connection option %s=%s", key,
value ? value : "(NULL)");
diff --git a/r/adbcsqlite/configure b/r/adbcsqlite/configure
index 95f48e83..d26c794d 100755
--- a/r/adbcsqlite/configure
+++ b/r/adbcsqlite/configure
@@ -50,6 +50,19 @@ if [ $? -ne 0 ] || [ ! -z "$FORCE_VENDORED_SQLITE3" ]; then
else
echo "Success!"
PKG_LIBS="$PKG_LIBS -lsqlite3"
+
+ # Apple -lsqlite3 does not contain sqlite3_load_extension()
+ echo "Testing SQLite for sqlite3_load_extension()"
+ PKG_CPPFLAGS="$PKG_CPPFLAGS" PKG_LIBS="$PKG_LIBS" \
+ $R_HOME/bin/R CMD SHLIB tools/test_extension.c -o sqlite_test >sqlite_test.log 2>&1
+
+ if [ $? -ne 0 ]; then
+ echo "Compile of sqlite3_load_extension() test failed"
+ cat sqlite_test.log
+ PKG_CPPFLAGS="$PKG_CPPFLAGS -DADBC_SQLITE_WITH_NO_LOAD_EXTENSION"
+ else
+ echo "Success!"
+ fi
fi
# Add mingw printf flag if on Windows
diff --git a/r/adbcsqlite/tools/test_extension.c b/r/adbcsqlite/tools/test_extension.c
new file mode 100644
index 00000000..6a35045a
--- /dev/null
+++ b/r/adbcsqlite/tools/test_extension.c
@@ -0,0 +1,21 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <sqlite3.h>
+#include <stddef.h>
+
+void try_load_extension() { sqlite3_load_extension(NULL, NULL, NULL, NULL); }