This is an automated email from the ASF dual-hosted git repository.
lidavidm 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 d0929c146 build(c/driver/sqlite): work around macOS modifications to
sqlite (#4860)
d0929c146 is described below
commit d0929c146b4d9125f3d8bc62337c17810886b0b0
Author: David Li <[email protected]>
AuthorDate: Tue Oct 6 18:08:56 2026 -0700
build(c/driver/sqlite): work around macOS modifications to sqlite (#4860)
Trimmed example of errors:
```
c/driver/sqlite/sqlite.cc:760:50: error: 'sqlite3_txn_state' is only
available on macOS 12.0 or newer [-Werror,-Wunguarded-availability-new]
/usr/include/sqlite3.h:6947:16: note: 'sqlite3_txn_state' has been marked
as being introduced in macOS 12.0 here, but the deployment target is macOS
10.15.0
c/driver/sqlite/sqlite.cc:760:50: note: enclose 'sqlite3_txn_state' in a
__builtin_available check to silence this warning
c/driver/sqlite/sqlite.cc:1168:43: error: 'sqlite3_total_changes64' is only
available on macOS 12.3 or newer [-Werror,-Wunguarded-availability-new]
/usr/include/sqlite3.h:2870:26: note: 'sqlite3_total_changes64' has been
marked as being introduced in macOS 12.3 here, but the deployment target is
macOS 10.15.0
/Users/runner/work/arrow-adbc/arrow-adbc/c/driver/sqlite/sqlite.cc:1168:43:
note: enclose 'sqlite3_total_changes64' in a __builtin_available check to
silence this warning
```
---
c/driver/sqlite/sqlite.cc | 43 ++++++++++++++++++++++++++++++++++++++-----
1 file changed, 38 insertions(+), 5 deletions(-)
diff --git a/c/driver/sqlite/sqlite.cc b/c/driver/sqlite/sqlite.cc
index f628b3d6e..e241797f4 100644
--- a/c/driver/sqlite/sqlite.cc
+++ b/c/driver/sqlite/sqlite.cc
@@ -34,15 +34,42 @@
#include "driver/sqlite/config.h"
#include "driver/sqlite/statement_reader.h"
+#if defined(__has_builtin)
+#if __has_builtin(__builtin_available)
+#define HAVE_BUILTIN_AVAILABLE
+#endif
+#endif
+
#if SQLITE_VERSION_NUMBER < 3037000
// Polyfill for older versions
-sqlite3_int64 sqlite3_total_changes64(sqlite3* db) {
+sqlite3_int64 polyfill_total_changes64(sqlite3* db) {
+ return static_cast<sqlite3_int64>(sqlite3_total_changes(db));
+}
+
+sqlite3_int64 polyfill_changes64(sqlite3* db) {
+ return static_cast<sqlite3_int64>(sqlite3_changes(db));
+}
+#elif defined(HAVE_BUILTIN_AVAILABLE)
+// Must branch at runtime for macOS
+sqlite3_int64 polyfill_total_changes64(sqlite3* db) {
+ if (__builtin_available(macOS 12.3, *)) {
+ return sqlite3_total_changes64(db);
+ }
return static_cast<sqlite3_int64>(sqlite3_total_changes(db));
}
-sqlite3_int64 sqlite3_changes64(sqlite3* db) {
+sqlite3_int64 polyfill_changes64(sqlite3* db) {
+ if (__builtin_available(macOS 12.3, *)) {
+ return sqlite3_changes64(db);
+ }
return static_cast<sqlite3_int64>(sqlite3_changes(db));
}
+#else
+sqlite3_int64 polyfill_total_changes64(sqlite3* db) {
+ return sqlite3_total_changes64(db);
+}
+
+sqlite3_int64 polyfill_changes64(sqlite3* db) { return sqlite3_changes64(db); }
#endif
namespace adbc::sqlite {
@@ -756,6 +783,12 @@ class SqliteConnection : public
driver::Connection<SqliteConnection> {
#if SQLITE_VERSION_NUMBER < 3034000
return status::NotImplemented(
"this version of SQLite does not support sqlite3_txn_state");
+#elif defined(HAVE_BUILTIN_AVAILABLE)
+ if (__builtin_available(macOS 12.0, *)) {
+ return driver::Option(static_cast<int64_t>(sqlite3_txn_state(conn_,
nullptr)));
+ }
+ return status::NotImplemented(
+ "this version of SQLite does not support sqlite3_txn_state");
#else
return driver::Option(static_cast<int64_t>(sqlite3_txn_state(conn_,
nullptr)));
#endif
@@ -1165,7 +1198,7 @@ class SqliteStatement : public
driver::Statement<SqliteStatement> {
}
}
- const sqlite3_int64 total_changes = sqlite3_total_changes64(conn_);
+ const sqlite3_int64 total_changes = polyfill_total_changes64(conn_);
while (sqlite3_step(stmt_) == SQLITE_ROW) {
output_rows++;
}
@@ -1173,8 +1206,8 @@ class SqliteStatement : public
driver::Statement<SqliteStatement> {
// NOTE(apache/arrow-adbc#4820): only count sqlite3_total_changes when
// it actually changed from before
if (sqlite3_column_count(stmt_) == 0 &&
- sqlite3_total_changes64(conn_) != total_changes) {
- changed_rows += sqlite3_changes64(conn_);
+ polyfill_total_changes64(conn_) != total_changes) {
+ changed_rows += polyfill_changes64(conn_);
}
if (!binder_.schema.release) break;