From 909902315d0053d8995f8d40297949c398748174 Mon Sep 17 00:00:00 2001
From: David Li
Date: Wed, 23 Apr 2025 16:52:10 +0900
Subject: [PATCH 01/16] fix(c): enable linking to static builds
Fixes #2562.
---
.github/workflows/nightly-verify.yml | 7 +-
c/CMakeLists.txt | 6 +
c/cmake_modules/BuildUtils.cmake | 34 +----
c/cmake_modules/DefineOptions.cmake | 27 +---
c/cmake_modules/GoUtils.cmake | 22 +++-
.../AdbcDriverBigQueryConfig.cmake.in | 2 +-
c/driver/bigquery/CMakeLists.txt | 2 +
.../common/AdbcDriverCommonConfig.cmake.in | 24 ++++
c/driver/common/CMakeLists.txt | 16 +++
c/driver/common/utils.c | 54 ++++----
c/driver/common/utils.h | 17 +--
c/driver/common/utils_test.cc | 49 +++----
.../AdbcDriverFlightSQLConfig.cmake.in | 2 +-
c/driver/flightsql/CMakeLists.txt | 2 +
.../AdbcDriverFrameworkConfig.cmake.in | 24 ++++
c/driver/framework/CMakeLists.txt | 21 ++-
.../AdbcDriverPostgreSQLConfig.cmake.in | 4 +
c/driver/postgresql/CMakeLists.txt | 4 +
c/driver/postgresql/copy/writer.h | 4 +-
c/driver/postgresql/postgres_type.h | 2 +-
c/driver/postgresql/postgresql.cc | 10 ++
c/driver/postgresql/postgresql_test.cc | 25 ++--
c/driver/postgresql/statement.cc | 6 +-
.../AdbcDriverSnowflakeConfig.cmake.in | 2 +-
c/driver/snowflake/CMakeLists.txt | 2 +
.../sqlite/AdbcDriverSQLiteConfig.cmake.in | 4 +
c/driver/sqlite/CMakeLists.txt | 4 +
c/driver/sqlite/sqlite.cc | 39 +++---
c/driver/sqlite/sqlite_test.cc | 8 +-
c/driver/sqlite/statement_reader.c | 43 +++---
c/driver/sqlite/statement_reader.h | 23 ++--
c/integration/static_test/CMakeLists.txt | 49 +++++++
c/integration/static_test/README.md | 23 ++++
c/integration/static_test/main.c | 78 +++++++++++
c/symbols.map | 2 +
c/validation/adbc_validation_connection.cc | 16 +--
c/validation/adbc_validation_util.h | 4 +-
ci/scripts/cpp_static_test.sh | 123 ++++++++++++++++++
compose.yaml | 10 ++
docs/source/cpp/index.rst | 1 +
docs/source/cpp/static_linking.rst | 64 +++++++++
go/adbc/pkg/_tmpl/utils.c.tmpl | 2 +
go/adbc/pkg/bigquery/utils.c | 2 +
go/adbc/pkg/flightsql/utils.c | 2 +
go/adbc/pkg/snowflake/utils.c | 2 +
45 files changed, 661 insertions(+), 206 deletions(-)
create mode 100644 c/driver/common/AdbcDriverCommonConfig.cmake.in
create mode 100644 c/driver/framework/AdbcDriverFrameworkConfig.cmake.in
create mode 100644 c/integration/static_test/CMakeLists.txt
create mode 100644 c/integration/static_test/README.md
create mode 100644 c/integration/static_test/main.c
create mode 100755 ci/scripts/cpp_static_test.sh
create mode 100644 docs/source/cpp/static_linking.rst
diff --git a/.github/workflows/nightly-verify.yml b/.github/workflows/nightly-verify.yml
index 5caa2b26c5..5acb64f457 100644
--- a/.github/workflows/nightly-verify.yml
+++ b/.github/workflows/nightly-verify.yml
@@ -201,10 +201,15 @@ jobs:
pushd arrow-adbc
docker compose run --rm cpp-gcc-latest
+ - name: cpp-static-test
+ run: |
+ pushd arrow-adbc
+ docker compose run --rm cpp-static-test
+
- name: python-debug
run: |
pushd arrow-adbc
- docker compose run -e PYTHON=3.12 --rm python-debug
+ env PYTHON=3.13 docker compose run --rm python-debug
source-verify-docker:
name: "Verify Source (OS)/${{ matrix.os }} ${{ matrix.version }}"
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt
index 746547636c..036645ebd8 100644
--- a/c/CMakeLists.txt
+++ b/c/CMakeLists.txt
@@ -29,6 +29,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(CTest)
+set(ADBC_TARGET_COMPILE_DEFINITIONS)
+if(NOT ADBC_DEFINE_COMMON_ENTRYPOINTS)
+ message(STATUS "Defining ADBC_NO_COMMON_ENTRYPOINTS")
+ set(ADBC_TARGET_COMPILE_DEFINITIONS "ADBC_NO_COMMON_ENTRYPOINTS")
+endif()
+
if(ADBC_WITH_VENDORED_FMT)
add_subdirectory(vendor/fmt EXCLUDE_FROM_ALL)
set_target_properties(fmt PROPERTIES POSITION_INDEPENDENT_CODE ON)
diff --git a/c/cmake_modules/BuildUtils.cmake b/c/cmake_modules/BuildUtils.cmake
index 55b726d305..db9a64a9eb 100644
--- a/c/cmake_modules/BuildUtils.cmake
+++ b/c/cmake_modules/BuildUtils.cmake
@@ -67,12 +67,6 @@ function(add_thirdparty_lib LIB_NAME LIB_TYPE LIB)
endif()
endfunction()
-function(REUSE_PRECOMPILED_HEADER_LIB TARGET_NAME LIB_NAME)
- if(ADBC_USE_PRECOMPILED_HEADERS)
- target_precompile_headers(${TARGET_NAME} REUSE_FROM ${LIB_NAME})
- endif()
-endfunction()
-
function(arrow_install_cmake_package PACKAGE_NAME EXPORT_NAME)
set(CONFIG_CMAKE "${PACKAGE_NAME}Config.cmake")
set(BUILT_CONFIG_CMAKE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_CMAKE}")
@@ -102,11 +96,9 @@ function(ADD_ARROW_LIB LIB_NAME)
BUILD_STATIC
CMAKE_PACKAGE_NAME
PKG_CONFIG_NAME
- SHARED_LINK_FLAGS
- PRECOMPILED_HEADER_LIB)
+ SHARED_LINK_FLAGS)
set(multi_value_args
SOURCES
- PRECOMPILED_HEADERS
OUTPUTS
STATIC_LINK_LIBS
SHARED_LINK_LIBS
@@ -172,12 +164,6 @@ function(ADD_ARROW_LIB LIB_NAME)
if(ARG_DEPENDENCIES)
add_dependencies(${LIB_NAME}_objlib ${ARG_DEPENDENCIES})
endif()
- if(ARG_PRECOMPILED_HEADER_LIB)
- reuse_precompiled_header_lib(${LIB_NAME}_objlib ${ARG_PRECOMPILED_HEADER_LIB})
- endif()
- if(ARG_PRECOMPILED_HEADERS AND ADBC_USE_PRECOMPILED_HEADERS)
- target_precompile_headers(${LIB_NAME}_objlib PRIVATE ${ARG_PRECOMPILED_HEADERS})
- endif()
set(LIB_DEPS $)
set(LIB_INCLUDES)
set(EXTRA_DEPS)
@@ -220,10 +206,6 @@ function(ADD_ARROW_LIB LIB_NAME)
add_dependencies(${LIB_NAME}_shared ${EXTRA_DEPS})
endif()
- if(ARG_PRECOMPILED_HEADER_LIB)
- reuse_precompiled_header_lib(${LIB_NAME}_shared ${ARG_PRECOMPILED_HEADER_LIB})
- endif()
-
if(ARG_OUTPUTS)
list(APPEND ${ARG_OUTPUTS} ${LIB_NAME}_shared)
endif()
@@ -318,10 +300,6 @@ function(ADD_ARROW_LIB LIB_NAME)
add_dependencies(${LIB_NAME}_static ${EXTRA_DEPS})
endif()
- if(ARG_PRECOMPILED_HEADER_LIB)
- reuse_precompiled_header_lib(${LIB_NAME}_static ${ARG_PRECOMPILED_HEADER_LIB})
- endif()
-
if(ARG_OUTPUTS)
list(APPEND ${ARG_OUTPUTS} ${LIB_NAME}_static)
endif()
@@ -550,10 +528,8 @@ endfunction()
# names must exist
function(ADD_TEST_CASE REL_TEST_NAME)
set(options NO_VALGRIND ENABLED)
- set(one_value_args PRECOMPILED_HEADER_LIB)
set(multi_value_args
SOURCES
- PRECOMPILED_HEADERS
STATIC_LINK_LIBS
EXTRA_LINK_LIBS
EXTRA_INCLUDES
@@ -613,14 +589,6 @@ function(ADD_TEST_CASE REL_TEST_NAME)
target_link_libraries(${TEST_NAME} PRIVATE ${ADBC_TEST_LINK_LIBS})
endif()
- if(ARG_PRECOMPILED_HEADER_LIB)
- reuse_precompiled_header_lib(${TEST_NAME} ${ARG_PRECOMPILED_HEADER_LIB})
- endif()
-
- if(ARG_PRECOMPILED_HEADERS AND ADBC_USE_PRECOMPILED_HEADERS)
- target_precompile_headers(${TEST_NAME} PRIVATE ${ARG_PRECOMPILED_HEADERS})
- endif()
-
if(ARG_EXTRA_LINK_LIBS)
target_link_libraries(${TEST_NAME} PRIVATE ${ARG_EXTRA_LINK_LIBS})
endif()
diff --git a/c/cmake_modules/DefineOptions.cmake b/c/cmake_modules/DefineOptions.cmake
index c022d523a1..d0e8085260 100644
--- a/c/cmake_modules/DefineOptions.cmake
+++ b/c/cmake_modules/DefineOptions.cmake
@@ -98,34 +98,13 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
define_option(ADBC_BUILD_SHARED "Build shared libraries" ON)
- define_option_string(ADBC_PACKAGE_KIND
- "Arbitrary string that identifies the kind of package;\
-(for informational purposes)" "")
-
define_option_string(ADBC_GIT_ID "The Arrow git commit id (if any)" "")
define_option_string(ADBC_GIT_DESCRIPTION "The Arrow git commit description (if any)"
"")
- define_option(ADBC_NO_DEPRECATED_API "Exclude deprecated APIs from build" OFF)
-
define_option(ADBC_USE_CCACHE "Use ccache when compiling (if available)" ON)
- define_option(ADBC_USE_PRECOMPILED_HEADERS "Use precompiled headers when compiling" OFF)
-
- # Arm64 architectures and extensions can lead to exploding combinations.
- # So set it directly through cmake command line.
- #
- # If you change this, you need to change the definition in
- # python/CMakeLists.txt too.
- define_option_string(ADBC_ARMV8_ARCH
- "Arm64 arch and extensions"
- "armv8-a" # Default
- "armv8-a"
- "armv8-a+crc+crypto")
-
- define_option(ADBC_ALTIVEC "Build with Altivec if compiler has support" ON)
-
define_option(ADBC_RPATH_ORIGIN "Build Arrow libraries with RATH set to \$ORIGIN" OFF)
define_option(ADBC_INSTALL_NAME_RPATH
@@ -230,7 +209,11 @@ if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
#----------------------------------------------------------------------
set_option_category("Advanced developer")
- option(ADBC_BUILD_CONFIG_SUMMARY_JSON "Summarize build configuration in a JSON file" ON)
+ define_option(ADBC_BUILD_CONFIG_SUMMARY_JSON
+ "Summarize build configuration in a JSON file" ON)
+
+ define_option(ADBC_DEFINE_COMMON_ENTRYPOINTS
+ "Define the Adbc functions in static/shared driver libraries" ON)
#----------------------------------------------------------------------
set_option_category("Project components")
diff --git a/c/cmake_modules/GoUtils.cmake b/c/cmake_modules/GoUtils.cmake
index 87b1a957c2..2342a33934 100644
--- a/c/cmake_modules/GoUtils.cmake
+++ b/c/cmake_modules/GoUtils.cmake
@@ -57,7 +57,7 @@ function(adbc_add_static_library target_name base_name)
PROPERTIES
IMPORTED_LOCATION "${_IMPORT_PREFIX}/bin/${static_base_name}")
else()
- set(prefix "${_IMPORT_PREFIX}/${ADBC_IMPORT_LIB_DIR}")
+ set(prefix "${_IMPORT_PREFIX}/${ADBC_INSTALL_LIBDIR}")
set_target_properties(${target_name}
PROPERTIES
IMPORTED_LOCATION "${prefix}/${static_base_name}")
@@ -74,7 +74,7 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME)
PKG_CONFIG_NAME
BUILD_STATIC
BUILD_SHARED)
- set(multi_value_args SOURCES OUTPUTS)
+ set(multi_value_args SOURCES DEFINES OUTPUTS)
cmake_parse_arguments(ARG
"${options}"
@@ -135,10 +135,20 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME)
"${GO_BUILD_FLAGS} $<$:-gcflags=\"-N -l\">")
# if we're building debug mode then change the default CGO_CFLAGS and CGO_CXXFLAGS from "-g O2" to "-g3"
- set(GO_ENV_VARS
- "CGO_ENABLED=1 $<$:CGO_CFLAGS=-g3> $<$:CGO_CXXFLAGS=-g3>"
- )
- separate_arguments(GO_ENV_VARS NATIVE_COMMAND "${GO_ENV_VARS}")
+ set(GO_FLAGS)
+ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+ set(GO_FLAGS "-g3")
+ endif()
+ string(JOIN " " GO_FLAGS "${GO_FLAGS}")
+
+ foreach(DEFINE ${ARG_DEFINES})
+ list(APPEND GO_FLAGS "-D${DEFINE}")
+ endforeach()
+
+ set(GO_ENV_VARS)
+ list(APPEND GO_ENV_VARS "CGO_ENABLED=1")
+ list(APPEND GO_ENV_VARS "CGO_CFLAGS=\"${GO_FLAGS}\"")
+ list(APPEND GO_ENV_VARS "CGO_CXXFLAGS=\"${GO_FLAGS}\"")
if(BUILD_SHARED)
set(LIB_NAME_SHARED
diff --git a/c/driver/bigquery/AdbcDriverBigQueryConfig.cmake.in b/c/driver/bigquery/AdbcDriverBigQueryConfig.cmake.in
index 98f5c44e45..9573ecf0a4 100644
--- a/c/driver/bigquery/AdbcDriverBigQueryConfig.cmake.in
+++ b/c/driver/bigquery/AdbcDriverBigQueryConfig.cmake.in
@@ -33,7 +33,7 @@ if(ADBC_BUILD_SHARED)
endif()
if(ADBC_BUILD_STATIC)
- adbc_add_shared_library(
+ adbc_add_static_library(
AdbcDriverBigQuery::adbc_driver_bigquery_static
adbc_driver_bigquery)
endif()
diff --git a/c/driver/bigquery/CMakeLists.txt b/c/driver/bigquery/CMakeLists.txt
index 94192908f6..7dc63b90bc 100644
--- a/c/driver/bigquery/CMakeLists.txt
+++ b/c/driver/bigquery/CMakeLists.txt
@@ -32,6 +32,8 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/bigquery/"
adbc-driver-bigquery
SHARED_LINK_FLAGS
${LDFLAGS}
+ DEFINES
+ ${ADBC_TARGET_COMPILE_DEFINITIONS}
OUTPUTS
ADBC_LIBRARIES)
diff --git a/c/driver/common/AdbcDriverCommonConfig.cmake.in b/c/driver/common/AdbcDriverCommonConfig.cmake.in
new file mode 100644
index 0000000000..165e0b6aaf
--- /dev/null
+++ b/c/driver/common/AdbcDriverCommonConfig.cmake.in
@@ -0,0 +1,24 @@
+# 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.
+
+@PACKAGE_INIT@
+
+set(ADBC_VERSION "@ADBC_VERSION@")
+
+include("${CMAKE_CURRENT_LIST_DIR}/AdbcDriverCommonTargets.cmake")
+
+check_required_components(AdbcDriverCommon)
diff --git a/c/driver/common/CMakeLists.txt b/c/driver/common/CMakeLists.txt
index 5855056bb4..07b9a50ad6 100644
--- a/c/driver/common/CMakeLists.txt
+++ b/c/driver/common/CMakeLists.txt
@@ -21,6 +21,22 @@ set_target_properties(adbc_driver_common PROPERTIES POSITION_INDEPENDENT_CODE ON
target_include_directories(adbc_driver_common PRIVATE "${REPOSITORY_ROOT}/c/include")
target_link_libraries(adbc_driver_common PUBLIC nanoarrow::nanoarrow)
+# For static builds, we need to install the static library here so downstream
+# applications can link to it
+if(ADBC_BUILD_STATIC)
+ if(ADBC_WITH_VENDORED_NANOARROW)
+ message(WARNING "adbc_driver_common is not installed when ADBC_WITH_VENDORED_NANOARROW is ON. To use the static libraries, for now you must provide nanoarrow instead of using the vendored copy"
+ )
+ else()
+ install(TARGETS adbc_driver_common ${INSTALL_IS_OPTIONAL}
+ EXPORT adbc_driver_common_targets
+ RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ arrow_install_cmake_package(AdbcDriverCommon adbc_driver_common_targets)
+ endif()
+endif()
+
if(ADBC_BUILD_TESTS)
add_test_case(driver_common_test
PREFIX
diff --git a/c/driver/common/utils.c b/c/driver/common/utils.c
index 00ebd51939..1b05429a64 100644
--- a/c/driver/common/utils.c
+++ b/c/driver/common/utils.c
@@ -27,7 +27,7 @@
static size_t kErrorBufferSize = 1024;
-int AdbcStatusCodeToErrno(AdbcStatusCode code) {
+int PrivateAdbcStatusCodeToErrno(AdbcStatusCode code) {
switch (code) {
case ADBC_STATUS_OK:
return 0;
@@ -285,9 +285,9 @@ void StringBuilderReset(struct StringBuilder* builder) {
memset(builder, 0, sizeof(*builder));
}
-AdbcStatusCode AdbcInitConnectionGetInfoSchema(struct ArrowSchema* schema,
- struct ArrowArray* array,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcInitConnectionGetInfoSchema(struct ArrowSchema* schema,
+ struct ArrowArray* array,
+ struct AdbcError* error) {
// TODO: use C equivalent of UniqueSchema to avoid incomplete schema
// on error
ArrowSchemaInit(schema);
@@ -351,10 +351,10 @@ AdbcStatusCode AdbcInitConnectionGetInfoSchema(struct ArrowSchema* schema,
return ADBC_STATUS_OK;
} // NOLINT(whitespace/indent)
-AdbcStatusCode AdbcConnectionGetInfoAppendString(struct ArrowArray* array,
- uint32_t info_code,
- const char* info_value,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcConnectionGetInfoAppendString(struct ArrowArray* array,
+ uint32_t info_code,
+ const char* info_value,
+ struct AdbcError* error) {
CHECK_NA(INTERNAL, ArrowArrayAppendUInt(array->children[0], info_code), error);
// Append to type variant
struct ArrowStringView value = ArrowCharView(info_value);
@@ -366,9 +366,10 @@ AdbcStatusCode AdbcConnectionGetInfoAppendString(struct ArrowArray* array,
return ADBC_STATUS_OK;
}
-AdbcStatusCode AdbcConnectionGetInfoAppendInt(struct ArrowArray* array,
- uint32_t info_code, int64_t info_value,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcConnectionGetInfoAppendInt(struct ArrowArray* array,
+ uint32_t info_code,
+ int64_t info_value,
+ struct AdbcError* error) {
CHECK_NA(INTERNAL, ArrowArrayAppendUInt(array->children[0], info_code), error);
// Append to type variant
CHECK_NA(INTERNAL, ArrowArrayAppendInt(array->children[1]->children[2], info_value),
@@ -379,8 +380,8 @@ AdbcStatusCode AdbcConnectionGetInfoAppendInt(struct ArrowArray* array,
return ADBC_STATUS_OK;
}
-AdbcStatusCode AdbcInitConnectionObjectsSchema(struct ArrowSchema* schema,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcInitConnectionObjectsSchema(struct ArrowSchema* schema,
+ struct AdbcError* error) {
ArrowSchemaInit(schema);
CHECK_NA(INTERNAL, ArrowSchemaSetTypeStruct(schema, /*num_columns=*/2), error);
CHECK_NA(INTERNAL, ArrowSchemaSetType(schema->children[0], NANOARROW_TYPE_STRING),
@@ -563,7 +564,8 @@ AdbcStatusCode AdbcInitConnectionObjectsSchema(struct ArrowSchema* schema,
return ADBC_STATUS_OK;
}
-struct AdbcGetObjectsData* AdbcGetObjectsDataInit(struct ArrowArrayView* array_view) {
+struct AdbcGetObjectsData* PrivateAdbcGetObjectsDataInit(
+ struct ArrowArrayView* array_view) {
struct AdbcGetObjectsData* get_objects_data =
(struct AdbcGetObjectsData*)calloc(1, sizeof(struct AdbcGetObjectsData));
if (get_objects_data == NULL) {
@@ -895,11 +897,11 @@ struct AdbcGetObjectsData* AdbcGetObjectsDataInit(struct ArrowArrayView* array_v
return get_objects_data;
error_handler:
- AdbcGetObjectsDataDelete(get_objects_data);
+ PrivateAdbcGetObjectsDataDelete(get_objects_data);
return NULL;
}
-void AdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data) {
+void PrivateAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data) {
for (int64_t catalog_index = 0; catalog_index < get_objects_data->n_catalogs;
catalog_index++) {
struct AdbcGetObjectsCatalog* catalog = get_objects_data->catalogs[catalog_index];
@@ -946,7 +948,7 @@ void AdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data) {
free(get_objects_data);
}
-struct AdbcGetObjectsCatalog* AdbcGetObjectsDataGetCatalogByName(
+struct AdbcGetObjectsCatalog* PrivateAdbcGetObjectsDataGetCatalogByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name) {
if (catalog_name != NULL) {
for (int64_t i = 0; i < get_objects_data->n_catalogs; i++) {
@@ -960,12 +962,12 @@ struct AdbcGetObjectsCatalog* AdbcGetObjectsDataGetCatalogByName(
return NULL;
}
-struct AdbcGetObjectsSchema* AdbcGetObjectsDataGetSchemaByName(
+struct AdbcGetObjectsSchema* PrivateAdbcGetObjectsDataGetSchemaByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name) {
if (schema_name != NULL) {
struct AdbcGetObjectsCatalog* catalog =
- AdbcGetObjectsDataGetCatalogByName(get_objects_data, catalog_name);
+ PrivateAdbcGetObjectsDataGetCatalogByName(get_objects_data, catalog_name);
if (catalog != NULL) {
for (int64_t i = 0; i < catalog->n_db_schemas; i++) {
struct AdbcGetObjectsSchema* schema = catalog->catalog_db_schemas[i];
@@ -979,12 +981,12 @@ struct AdbcGetObjectsSchema* AdbcGetObjectsDataGetSchemaByName(
return NULL;
}
-struct AdbcGetObjectsTable* AdbcGetObjectsDataGetTableByName(
+struct AdbcGetObjectsTable* PrivateAdbcGetObjectsDataGetTableByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name) {
if (table_name != NULL) {
- struct AdbcGetObjectsSchema* schema =
- AdbcGetObjectsDataGetSchemaByName(get_objects_data, catalog_name, schema_name);
+ struct AdbcGetObjectsSchema* schema = PrivateAdbcGetObjectsDataGetSchemaByName(
+ get_objects_data, catalog_name, schema_name);
if (schema != NULL) {
for (int64_t i = 0; i < schema->n_db_schema_tables; i++) {
struct AdbcGetObjectsTable* table = schema->db_schema_tables[i];
@@ -998,12 +1000,12 @@ struct AdbcGetObjectsTable* AdbcGetObjectsDataGetTableByName(
return NULL;
}
-struct AdbcGetObjectsColumn* AdbcGetObjectsDataGetColumnByName(
+struct AdbcGetObjectsColumn* PrivateAdbcGetObjectsDataGetColumnByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const column_name) {
if (column_name != NULL) {
- struct AdbcGetObjectsTable* table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
get_objects_data, catalog_name, schema_name, table_name);
if (table != NULL) {
for (int64_t i = 0; i < table->n_table_columns; i++) {
@@ -1018,12 +1020,12 @@ struct AdbcGetObjectsColumn* AdbcGetObjectsDataGetColumnByName(
return NULL;
}
-struct AdbcGetObjectsConstraint* AdbcGetObjectsDataGetConstraintByName(
+struct AdbcGetObjectsConstraint* PrivateAdbcGetObjectsDataGetConstraintByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const constraint_name) {
if (constraint_name != NULL) {
- struct AdbcGetObjectsTable* table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
get_objects_data, catalog_name, schema_name, table_name);
if (table != NULL) {
for (int64_t i = 0; i < table->n_table_constraints; i++) {
diff --git a/c/driver/common/utils.h b/c/driver/common/utils.h
index d204821b2b..5872c12960 100644
--- a/c/driver/common/utils.h
+++ b/c/driver/common/utils.h
@@ -29,7 +29,7 @@
extern "C" {
#endif
-int AdbcStatusCodeToErrno(AdbcStatusCode code);
+int PrivateAdbcStatusCodeToErrno(AdbcStatusCode code);
// If using mingw's c99-compliant printf, we need a different format-checking attribute
#if defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW_PRINTF_FORMAT)
@@ -217,24 +217,25 @@ struct AdbcGetObjectsData {
// does not copy any data from array
// returns NULL on error
-struct AdbcGetObjectsData* AdbcGetObjectsDataInit(struct ArrowArrayView* array_view);
-void AdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data);
+struct AdbcGetObjectsData* PrivateAdbcGetObjectsDataInit(
+ struct ArrowArrayView* array_view);
+void PrivateAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data);
// returns NULL on error
// for now all arguments are required
-struct AdbcGetObjectsCatalog* AdbcGetObjectsDataGetCatalogByName(
+struct AdbcGetObjectsCatalog* PrivateAdbcGetObjectsDataGetCatalogByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name);
-struct AdbcGetObjectsSchema* AdbcGetObjectsDataGetSchemaByName(
+struct AdbcGetObjectsSchema* PrivateAdbcGetObjectsDataGetSchemaByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name);
-struct AdbcGetObjectsTable* AdbcGetObjectsDataGetTableByName(
+struct AdbcGetObjectsTable* PrivateAdbcGetObjectsDataGetTableByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name);
-struct AdbcGetObjectsColumn* AdbcGetObjectsDataGetColumnByName(
+struct AdbcGetObjectsColumn* PrivateAdbcGetObjectsDataGetColumnByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const column_name);
-struct AdbcGetObjectsConstraint* AdbcGetObjectsDataGetConstraintByName(
+struct AdbcGetObjectsConstraint* PrivateAdbcGetObjectsDataGetConstraintByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const constraint_name);
diff --git a/c/driver/common/utils_test.cc b/c/driver/common/utils_test.cc
index 489af163fd..07dbcb7620 100644
--- a/c/driver/common/utils_test.cc
+++ b/c/driver/common/utils_test.cc
@@ -209,42 +209,45 @@ TEST(AdbcGetObjectsData, GetObjectsByName) {
mock_table.table_constraints = constraints;
mock_table.n_table_constraints = 2;
- EXPECT_EQ(AdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog", "mock_schema",
- "table"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
+ "mock_schema", "table"),
&mock_table);
- EXPECT_EQ(AdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog", "mock_schema",
- "table_suffix"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
+ "mock_schema", "table_suffix"),
&mock_table_suffix);
- EXPECT_EQ(AdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog", "mock_schema",
- "nonexistent"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
+ "mock_schema", "nonexistent"),
nullptr);
- EXPECT_EQ(AdbcGetObjectsDataGetCatalogByName(&mock_data, "mock_catalog"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetCatalogByName(&mock_data, "mock_catalog"),
&mock_catalog);
- EXPECT_EQ(AdbcGetObjectsDataGetCatalogByName(&mock_data, "nonexistent"), nullptr);
-
- EXPECT_EQ(AdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog", "mock_schema"),
- &mock_schema);
- EXPECT_EQ(AdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog", "nonexistent"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetCatalogByName(&mock_data, "nonexistent"),
nullptr);
- EXPECT_EQ(AdbcGetObjectsDataGetColumnByName(&mock_data, "mock_catalog", "mock_schema",
- "table", "column"),
+ EXPECT_EQ(
+ PrivateAdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog", "mock_schema"),
+ &mock_schema);
+ EXPECT_EQ(
+ PrivateAdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog", "nonexistent"),
+ nullptr);
+
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetColumnByName(&mock_data, "mock_catalog",
+ "mock_schema", "table", "column"),
&mock_column);
- EXPECT_EQ(AdbcGetObjectsDataGetColumnByName(&mock_data, "mock_catalog", "mock_schema",
- "table", "column_suffix"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetColumnByName(
+ &mock_data, "mock_catalog", "mock_schema", "table", "column_suffix"),
&mock_column_suffix);
- EXPECT_EQ(AdbcGetObjectsDataGetColumnByName(&mock_data, "mock_catalog", "mock_schema",
- "table", "nonexistent"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetColumnByName(
+ &mock_data, "mock_catalog", "mock_schema", "table", "nonexistent"),
nullptr);
- EXPECT_EQ(AdbcGetObjectsDataGetConstraintByName(&mock_data, "mock_catalog",
- "mock_schema", "table", "constraint"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetConstraintByName(
+ &mock_data, "mock_catalog", "mock_schema", "table", "constraint"),
&mock_constraint);
- EXPECT_EQ(AdbcGetObjectsDataGetConstraintByName(
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetConstraintByName(
&mock_data, "mock_catalog", "mock_schema", "table", "constraint_suffix"),
&mock_constraint_suffix);
- EXPECT_EQ(AdbcGetObjectsDataGetConstraintByName(&mock_data, "mock_catalog",
- "mock_schema", "table", "nonexistent"),
+ EXPECT_EQ(PrivateAdbcGetObjectsDataGetConstraintByName(
+ &mock_data, "mock_catalog", "mock_schema", "table", "nonexistent"),
nullptr);
}
diff --git a/c/driver/flightsql/AdbcDriverFlightSQLConfig.cmake.in b/c/driver/flightsql/AdbcDriverFlightSQLConfig.cmake.in
index d43363266d..c414275852 100644
--- a/c/driver/flightsql/AdbcDriverFlightSQLConfig.cmake.in
+++ b/c/driver/flightsql/AdbcDriverFlightSQLConfig.cmake.in
@@ -33,7 +33,7 @@ if(ADBC_BUILD_SHARED)
endif()
if(ADBC_BUILD_STATIC)
- adbc_add_shared_library(
+ adbc_add_static_library(
AdbcDriverFlightSQL::adbc_driver_flightsql_static
adbc_driver_flightsql)
endif()
diff --git a/c/driver/flightsql/CMakeLists.txt b/c/driver/flightsql/CMakeLists.txt
index 2983c6a49c..9f60cbf07a 100644
--- a/c/driver/flightsql/CMakeLists.txt
+++ b/c/driver/flightsql/CMakeLists.txt
@@ -32,6 +32,8 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/flightsql/"
adbc-driver-flightsql
SHARED_LINK_FLAGS
${LDFLAGS}
+ DEFINES
+ ${ADBC_TARGET_COMPILE_DEFINITIONS}
OUTPUTS
ADBC_LIBRARIES)
diff --git a/c/driver/framework/AdbcDriverFrameworkConfig.cmake.in b/c/driver/framework/AdbcDriverFrameworkConfig.cmake.in
new file mode 100644
index 0000000000..09a2ea3096
--- /dev/null
+++ b/c/driver/framework/AdbcDriverFrameworkConfig.cmake.in
@@ -0,0 +1,24 @@
+# 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.
+
+@PACKAGE_INIT@
+
+set(ADBC_VERSION "@ADBC_VERSION@")
+
+include("${CMAKE_CURRENT_LIST_DIR}/AdbcDriverFrameworkTargets.cmake")
+
+check_required_components(AdbcDriverFramework)
diff --git a/c/driver/framework/CMakeLists.txt b/c/driver/framework/CMakeLists.txt
index fa2e03b978..464f3640cf 100644
--- a/c/driver/framework/CMakeLists.txt
+++ b/c/driver/framework/CMakeLists.txt
@@ -20,11 +20,26 @@ include(FetchContent)
add_library(adbc_driver_framework STATIC objects.cc utility.cc)
adbc_configure_target(adbc_driver_framework)
set_target_properties(adbc_driver_framework PROPERTIES POSITION_INDEPENDENT_CODE ON)
-target_include_directories(adbc_driver_framework
- PRIVATE "${REPOSITORY_ROOT}/c/" "${REPOSITORY_ROOT}/c/include"
- "${REPOSITORY_ROOT}/c/vendor")
+target_include_directories(adbc_driver_framework PRIVATE "${REPOSITORY_ROOT}/c/"
+ "${REPOSITORY_ROOT}/c/include")
target_link_libraries(adbc_driver_framework PUBLIC adbc_driver_common fmt::fmt)
+# For static builds, we need to install the static library here so downstream
+# applications can link to it
+if(ADBC_BUILD_STATIC)
+ if(ADBC_WITH_VENDORED_FMT OR ADBC_WITH_VENDORED_NANOARROW)
+ message(WARNING "adbc_driver_framework is not installed when ADBC_WITH_VENDORED_FMT or ADBC_WITH_VENDORED_NANOARROW are ON. To use the static libraries, for now you must provide these dependencies instead of using the vendored copies"
+ )
+ else()
+ install(TARGETS adbc_driver_framework ${INSTALL_IS_OPTIONAL}
+ EXPORT adbc_driver_framework_targets
+ RUNTIME DESTINATION ${RUNTIME_INSTALL_DIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ arrow_install_cmake_package(AdbcDriverFramework adbc_driver_framework_targets)
+ endif()
+endif()
+
if(ADBC_BUILD_TESTS)
add_test_case(driver_framework_test
PREFIX
diff --git a/c/driver/postgresql/AdbcDriverPostgreSQLConfig.cmake.in b/c/driver/postgresql/AdbcDriverPostgreSQLConfig.cmake.in
index c879d18e6b..30a22c3a7a 100644
--- a/c/driver/postgresql/AdbcDriverPostgreSQLConfig.cmake.in
+++ b/c/driver/postgresql/AdbcDriverPostgreSQLConfig.cmake.in
@@ -17,8 +17,12 @@
@PACKAGE_INIT@
+include(CMakeFindDependencyMacro)
+
set(ADBC_VERSION "@ADBC_VERSION@")
include("${CMAKE_CURRENT_LIST_DIR}/AdbcDriverPostgreSQLTargets.cmake")
+find_dependency(PostgreSQL)
+
check_required_components(AdbcDriverPostgreSQL)
diff --git a/c/driver/postgresql/CMakeLists.txt b/c/driver/postgresql/CMakeLists.txt
index 92c4c9f92d..e044a20d14 100644
--- a/c/driver/postgresql/CMakeLists.txt
+++ b/c/driver/postgresql/CMakeLists.txt
@@ -58,6 +58,10 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES})
target_include_directories(${LIB_TARGET} SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
${LIBPQ_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
+
+ if(NOT ADBC_DEFINE_COMMON_ENTRYPOINTS)
+ target_compile_definitions(${LIB_TARGET} PRIVATE ${ADBC_TARGET_COMPILE_DEFINITIONS})
+ endif()
endforeach()
if(ADBC_TEST_LINKAGE STREQUAL "shared")
diff --git a/c/driver/postgresql/copy/writer.h b/c/driver/postgresql/copy/writer.h
index e88ed691cd..1c3176ab34 100644
--- a/c/driver/postgresql/copy/writer.h
+++ b/c/driver/postgresql/copy/writer.h
@@ -498,9 +498,9 @@ class PostgresCopyListFieldWriter : public PostgresCopyFieldWriter {
NANOARROW_RETURN_NOT_OK(WriteChecked(buffer, lb, error));
}
- ArrowBufferAppend(buffer, tmp->data, tmp->size_bytes);
+ NANOARROW_RETURN_NOT_OK(ArrowBufferAppend(buffer, tmp->data, tmp->size_bytes));
- return ADBC_STATUS_OK;
+ return NANOARROW_OK;
}
private:
diff --git a/c/driver/postgresql/postgres_type.h b/c/driver/postgresql/postgres_type.h
index d2a5356293..8c331b4185 100644
--- a/c/driver/postgresql/postgres_type.h
+++ b/c/driver/postgresql/postgres_type.h
@@ -349,7 +349,7 @@ class PostgresType {
!typname_.empty() ? typname_.c_str() : PostgresTypname(type_id_);
nanoarrow::UniqueBuffer buffer;
- ArrowMetadataBuilderInit(buffer.get(), nullptr);
+ NANOARROW_RETURN_NOT_OK(ArrowMetadataBuilderInit(buffer.get(), nullptr));
// TODO(lidavidm): we have deprecated this in favor of arrow.opaque,
// remove once we feel enough time has passed
NANOARROW_RETURN_NOT_OK(ArrowMetadataBuilderAppend(
diff --git a/c/driver/postgresql/postgresql.cc b/c/driver/postgresql/postgresql.cc
index e43db98879..ea4d354279 100644
--- a/c/driver/postgresql/postgresql.cc
+++ b/c/driver/postgresql/postgresql.cc
@@ -82,6 +82,7 @@ struct AdbcErrorDetail PostgresErrorGetDetail(const struct AdbcError* error, int
}
} // namespace
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
int AdbcErrorGetDetailCount(const struct AdbcError* error) {
return PostgresErrorGetDetailCount(error);
}
@@ -94,6 +95,7 @@ const struct AdbcError* AdbcErrorFromArrayStream(struct ArrowArrayStream* stream
AdbcStatusCode* status) {
return PostgresErrorFromArrayStream(stream, status);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
// ---------------------------------------------------------------------
// AdbcDatabase
@@ -195,6 +197,7 @@ AdbcStatusCode PostgresDatabaseSetOptionInt(struct AdbcDatabase* database,
}
} // namespace
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
AdbcStatusCode AdbcDatabaseGetOption(struct AdbcDatabase* database, const char* key,
char* value, size_t* length,
struct AdbcError* error) {
@@ -250,6 +253,7 @@ AdbcStatusCode AdbcDatabaseSetOptionDouble(struct AdbcDatabase* database, const
double value, struct AdbcError* error) {
return PostgresDatabaseSetOptionDouble(database, key, value, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
// ---------------------------------------------------------------------
// AdbcConnection
@@ -450,6 +454,7 @@ AdbcStatusCode PostgresConnectionSetOptionInt(struct AdbcConnection* connection,
} // namespace
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection,
struct AdbcError* error) {
return PostgresConnectionCancel(connection, error);
@@ -584,6 +589,7 @@ AdbcStatusCode AdbcConnectionSetOptionDouble(struct AdbcConnection* connection,
struct AdbcError* error) {
return PostgresConnectionSetOptionDouble(connection, key, value, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
// ---------------------------------------------------------------------
// AdbcStatement
@@ -761,6 +767,7 @@ AdbcStatusCode PostgresStatementSetSqlQuery(struct AdbcStatement* statement,
}
} // namespace
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
AdbcStatusCode AdbcStatementBind(struct AdbcStatement* statement,
struct ArrowArray* values, struct ArrowSchema* schema,
struct AdbcError* error) {
@@ -870,6 +877,7 @@ AdbcStatusCode AdbcStatementSetSqlQuery(struct AdbcStatement* statement,
const char* query, struct AdbcError* error) {
return PostgresStatementSetSqlQuery(statement, query, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
extern "C" {
ADBC_EXPORT
@@ -951,8 +959,10 @@ AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
return ADBC_STATUS_OK;
}
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* raw_driver, struct AdbcError* error) {
return PostgresqlDriverInit(version, raw_driver, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
}
diff --git a/c/driver/postgresql/postgresql_test.cc b/c/driver/postgresql/postgresql_test.cc
index 5167dbef71..3cec988cfd 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -343,7 +343,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetCatalogs) {
auto catalogs = {"postgres", "template0", "template1"};
for (auto catalog : catalogs) {
struct AdbcGetObjectsCatalog* cat =
- AdbcGetObjectsDataGetCatalogByName(*get_objects_data, catalog);
+ PrivateAdbcGetObjectsDataGetCatalogByName(*get_objects_data, catalog);
ASSERT_NE(cat, nullptr) << "catalog " << catalog << " not found";
}
}
@@ -367,7 +367,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetDbSchemas) {
<< "could not initialize the AdbcGetObjectsData object";
struct AdbcGetObjectsSchema* schema =
- AdbcGetObjectsDataGetSchemaByName(*get_objects_data, "postgres", "public");
+ PrivateAdbcGetObjectsDataGetSchemaByName(*get_objects_data, "postgres", "public");
ASSERT_NE(schema, nullptr) << "schema public not found";
}
@@ -411,12 +411,12 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsPrimaryKey) {
ASSERT_NE(*get_objects_data, nullptr)
<< "could not initialize the AdbcGetObjectsData object";
- struct AdbcGetObjectsTable* table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_pkey_test");
ASSERT_NE(table, nullptr) << "could not find adbc_pkey_test table";
ASSERT_EQ(table->n_table_columns, 2);
- struct AdbcGetObjectsColumn* column = AdbcGetObjectsDataGetColumnByName(
+ struct AdbcGetObjectsColumn* column = PrivateAdbcGetObjectsDataGetColumnByName(
*get_objects_data, "postgres", "public", "adbc_pkey_test", "id");
ASSERT_NE(column, nullptr) << "could not find id column on adbc_pkey_test table";
@@ -424,8 +424,10 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsPrimaryKey) {
<< "expected 1 constraint on adbc_pkey_test table, found: "
<< table->n_table_constraints;
- struct AdbcGetObjectsConstraint* constraint = AdbcGetObjectsDataGetConstraintByName(
- *get_objects_data, "postgres", "public", "adbc_pkey_test", "adbc_pkey_test_pkey");
+ struct AdbcGetObjectsConstraint* constraint =
+ PrivateAdbcGetObjectsDataGetConstraintByName(*get_objects_data, "postgres",
+ "public", "adbc_pkey_test",
+ "adbc_pkey_test_pkey");
ASSERT_NE(constraint, nullptr) << "could not find adbc_pkey_test_pkey constraint";
auto constraint_type = std::string(constraint->constraint_type.data,
@@ -503,7 +505,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsForeignKey) {
ASSERT_NE(*get_objects_data, nullptr)
<< "could not initialize the AdbcGetInfoData object";
- struct AdbcGetObjectsTable* table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_fkey_test");
ASSERT_NE(table, nullptr) << "could not find adbc_fkey_test table";
ASSERT_EQ(table->n_table_constraints, 1)
@@ -513,8 +515,9 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsForeignKey) {
const std::string version = adbc_validation::GetDriverVendorVersion(&connection);
const std::string search_name =
version < "120000" ? "adbc_fkey_test_fid1_fkey" : "adbc_fkey_test_fid1_fid2_fkey";
- struct AdbcGetObjectsConstraint* constraint = AdbcGetObjectsDataGetConstraintByName(
- *get_objects_data, "postgres", "public", "adbc_fkey_test", search_name.c_str());
+ struct AdbcGetObjectsConstraint* constraint =
+ PrivateAdbcGetObjectsDataGetConstraintByName(
+ *get_objects_data, "postgres", "public", "adbc_fkey_test", search_name.c_str());
ASSERT_NE(constraint, nullptr) << "could not find " << search_name << " constraint";
auto constraint_type = std::string(constraint->constraint_type.data,
@@ -615,11 +618,11 @@ TEST_F(PostgresConnectionTest, GetObjectsTableTypesFilter) {
ASSERT_NE(*get_objects_data, nullptr)
<< "could not initialize the AdbcGetInfoData object";
- struct AdbcGetObjectsTable* table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_table_types_table_test");
ASSERT_EQ(table, nullptr) << "unexpected table adbc_table_types_table_test found";
- struct AdbcGetObjectsTable* view = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* view = PrivateAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_table_types_view_test");
ASSERT_NE(view, nullptr) << "did not find view adbc_table_types_view_test";
}
diff --git a/c/driver/postgresql/statement.cc b/c/driver/postgresql/statement.cc
index a83bca13f5..444d8b35c7 100644
--- a/c/driver/postgresql/statement.cc
+++ b/c/driver/postgresql/statement.cc
@@ -59,7 +59,7 @@ int TupleReader::GetSchema(struct ArrowSchema* out) {
if (out->release == nullptr) {
SetError(&error_, "[libpq] Result set was already consumed or freed");
status_ = ADBC_STATUS_INVALID_STATE;
- return AdbcStatusCodeToErrno(status_);
+ return PrivateAdbcStatusCodeToErrno(status_);
} else if (na_res != NANOARROW_OK) {
// e.g., Can't allocate memory
SetError(&error_, "[libpq] Error copying schema");
@@ -82,7 +82,7 @@ int TupleReader::GetCopyData() {
if (get_copy_res == -2) {
SetError(&error_, "[libpq] PQgetCopyData() failed: %s", PQerrorMessage(conn_));
status_ = ADBC_STATUS_IO;
- return AdbcStatusCodeToErrno(status_);
+ return PrivateAdbcStatusCodeToErrno(status_);
}
if (get_copy_res == -1) {
@@ -93,7 +93,7 @@ int TupleReader::GetCopyData() {
if (pq_status != PGRES_COMMAND_OK) {
status_ = SetError(&error_, result_, "[libpq] Execution error [%s]: %s",
PQresStatus(pq_status), PQresultErrorMessage(result_));
- return AdbcStatusCodeToErrno(status_);
+ return PrivateAdbcStatusCodeToErrno(status_);
} else {
return ENODATA;
}
diff --git a/c/driver/snowflake/AdbcDriverSnowflakeConfig.cmake.in b/c/driver/snowflake/AdbcDriverSnowflakeConfig.cmake.in
index 7bb51d15b8..04d5397adc 100644
--- a/c/driver/snowflake/AdbcDriverSnowflakeConfig.cmake.in
+++ b/c/driver/snowflake/AdbcDriverSnowflakeConfig.cmake.in
@@ -33,7 +33,7 @@ if(ADBC_BUILD_SHARED)
endif()
if(ADBC_BUILD_STATIC)
- adbc_add_shared_library(
+ adbc_add_static_library(
AdbcDriverSnowflake::adbc_driver_snowflake_static
adbc_driver_snowflake)
endif()
diff --git a/c/driver/snowflake/CMakeLists.txt b/c/driver/snowflake/CMakeLists.txt
index f70d507355..2a81eb2c49 100644
--- a/c/driver/snowflake/CMakeLists.txt
+++ b/c/driver/snowflake/CMakeLists.txt
@@ -32,6 +32,8 @@ add_go_lib("${REPOSITORY_ROOT}/go/adbc/pkg/snowflake/"
adbc-driver-snowflake
SHARED_LINK_FLAGS
${LDFLAGS}
+ DEFINES
+ ${ADBC_TARGET_COMPILE_DEFINITIONS}
OUTPUTS
ADBC_LIBRARIES)
diff --git a/c/driver/sqlite/AdbcDriverSQLiteConfig.cmake.in b/c/driver/sqlite/AdbcDriverSQLiteConfig.cmake.in
index cea8cf27f4..6310ff1861 100644
--- a/c/driver/sqlite/AdbcDriverSQLiteConfig.cmake.in
+++ b/c/driver/sqlite/AdbcDriverSQLiteConfig.cmake.in
@@ -17,8 +17,12 @@
@PACKAGE_INIT@
+include(CMakeFindDependencyMacro)
+
set(ADBC_VERSION "@ADBC_VERSION@")
include("${CMAKE_CURRENT_LIST_DIR}/AdbcDriverSQLiteTargets.cmake")
+find_dependency(SQLite3)
+
check_required_components(AdbcDriverSQLite)
diff --git a/c/driver/sqlite/CMakeLists.txt b/c/driver/sqlite/CMakeLists.txt
index 1b097546cd..4c6bb1f1a7 100644
--- a/c/driver/sqlite/CMakeLists.txt
+++ b/c/driver/sqlite/CMakeLists.txt
@@ -64,6 +64,10 @@ foreach(LIB_TARGET ${ADBC_LIBRARIES})
target_include_directories(${LIB_TARGET} SYSTEM
PRIVATE ${REPOSITORY_ROOT}/c/ ${REPOSITORY_ROOT}/c/include/
${SQLite3_INCLUDE_DIRS} ${REPOSITORY_ROOT}/c/driver)
+
+ if(NOT ADBC_DEFINE_COMMON_ENTRYPOINTS)
+ target_compile_definitions(${LIB_TARGET} PRIVATE ${ADBC_TARGET_COMPILE_DEFINITIONS})
+ endif()
endforeach()
include(CheckTypeSize)
diff --git a/c/driver/sqlite/sqlite.cc b/c/driver/sqlite/sqlite.cc
index 2fbe80d39a..5656f0337c 100644
--- a/c/driver/sqlite/sqlite.cc
+++ b/c/driver/sqlite/sqlite.cc
@@ -600,8 +600,8 @@ class SqliteConnection : public driver::Connection {
nanoarrow::UniqueArrayStream stream;
struct AdbcError error = ADBC_ERROR_INIT;
AdbcStatusCode status =
- AdbcSqliteExportReader(conn_, stmt, /*binder=*/NULL,
- /*batch_size=*/64, stream.get(), &error);
+ PrivateAdbcSqliteExportReader(conn_, stmt, /*binder=*/NULL,
+ /*batch_size=*/64, stream.get(), &error);
if (status == ADBC_STATUS_OK) {
int code = stream->get_schema(stream.get(), schema);
if (code != 0) {
@@ -767,7 +767,7 @@ class SqliteStatement : public driver::Statement {
if (bind_parameters_.release) {
struct AdbcError error = ADBC_ERROR_INIT;
if (AdbcStatusCode code =
- AdbcSqliteBinderSetArrayStream(&binder_, &bind_parameters_, &error);
+ PrivateAdbcSqliteBinderSetArrayStream(&binder_, &bind_parameters_, &error);
code != ADBC_STATUS_OK) {
return Status::FromAdbc(code, error);
}
@@ -938,7 +938,8 @@ class SqliteStatement : public driver::Statement {
struct AdbcError error = ADBC_ERROR_INIT;
while (true) {
char finished = 0;
- status_code = AdbcSqliteBinderBindNext(&binder_, conn_, stmt, &finished, &error);
+ status_code =
+ PrivateAdbcSqliteBinderBindNext(&binder_, conn_, stmt, &finished, &error);
if (status_code != ADBC_STATUS_OK || finished) {
status = Status::FromAdbc(status_code, error);
break;
@@ -983,9 +984,9 @@ class SqliteStatement : public driver::Statement {
"parameter count mismatch: expected {} but found {}", expected, actual);
}
- auto status =
- AdbcSqliteExportReader(conn_, stmt_, binder_.schema.release ? &binder_ : nullptr,
- batch_size_, stream, &error);
+ auto status = PrivateAdbcSqliteExportReader(
+ conn_, stmt_, binder_.schema.release ? &binder_ : nullptr, batch_size_, stream,
+ &error);
if (status != ADBC_STATUS_OK) {
return Status::FromAdbc(status, error);
}
@@ -1020,10 +1021,10 @@ class SqliteStatement : public driver::Statement {
if (binder_.schema.release) {
char finished = 0;
struct AdbcError error = ADBC_ERROR_INIT;
- if (AdbcStatusCode code =
- AdbcSqliteBinderBindNext(&binder_, conn_, stmt_, &finished, &error);
+ if (AdbcStatusCode code = PrivateAdbcSqliteBinderBindNext(&binder_, conn_, stmt_,
+ &finished, &error);
code != ADBC_STATUS_OK) {
- AdbcSqliteBinderRelease(&binder_);
+ PrivateAdbcSqliteBinderRelease(&binder_);
return Status::FromAdbc(code, error);
} else if (finished != 0) {
break;
@@ -1040,7 +1041,7 @@ class SqliteStatement : public driver::Statement {
if (!binder_.schema.release) break;
}
- AdbcSqliteBinderRelease(&binder_);
+ PrivateAdbcSqliteBinderRelease(&binder_);
if (sqlite3_reset(stmt_) != SQLITE_OK) {
const char* msg = sqlite3_errmsg(conn_);
@@ -1127,7 +1128,7 @@ class SqliteStatement : public driver::Statement {
rc, sqlite3_errmsg(conn_));
}
}
- AdbcSqliteBinderRelease(&binder_);
+ PrivateAdbcSqliteBinderRelease(&binder_);
return Statement::ReleaseImpl();
}
@@ -1159,6 +1160,8 @@ using SqliteDriver =
// Public names
+extern "C" {
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
AdbcStatusCode AdbcDatabaseGetOption(struct AdbcDatabase* database, const char* key,
char* value, size_t* length,
struct AdbcError* error) {
@@ -1477,7 +1480,12 @@ AdbcStatusCode AdbcStatementExecutePartitions(struct AdbcStatement* statement,
statement, schema, partitions, rows_affected, error);
}
-extern "C" {
+[[maybe_unused]] ADBC_EXPORT AdbcStatusCode AdbcDriverInit(int version, void* raw_driver,
+ AdbcError* error) {
+ return adbc::sqlite::SqliteDriver::Init(version, raw_driver, error);
+}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
+
[[maybe_unused]] ADBC_EXPORT AdbcStatusCode AdbcDriverSqliteInit(int version,
void* raw_driver,
AdbcError* error) {
@@ -1489,9 +1497,4 @@ extern "C" {
AdbcError* error) {
return adbc::sqlite::SqliteDriver::Init(version, raw_driver, error);
}
-
-[[maybe_unused]] ADBC_EXPORT AdbcStatusCode AdbcDriverInit(int version, void* raw_driver,
- AdbcError* error) {
- return adbc::sqlite::SqliteDriver::Init(version, raw_driver, error);
-}
}
diff --git a/c/driver/sqlite/sqlite_test.cc b/c/driver/sqlite/sqlite_test.cc
index f6ee0c1ab2..e6fcf3d6fc 100644
--- a/c/driver/sqlite/sqlite_test.cc
+++ b/c/driver/sqlite/sqlite_test.cc
@@ -439,7 +439,7 @@ class SqliteReaderTest : public ::testing::Test {
}
void TearDown() override {
if (error.release) error.release(&error);
- AdbcSqliteBinderRelease(&binder);
+ PrivateAdbcSqliteBinderRelease(&binder);
sqlite3_finalize(stmt);
sqlite3_close(db);
}
@@ -463,7 +463,7 @@ class SqliteReaderTest : public ::testing::Test {
}
void Bind(struct ArrowArrayStream* stream) {
- ASSERT_THAT(AdbcSqliteBinderSetArrayStream(&binder, stream, &error),
+ ASSERT_THAT(PrivateAdbcSqliteBinderSetArrayStream(&binder, stream, &error),
IsOkStatus(&error));
}
@@ -482,8 +482,8 @@ class SqliteReaderTest : public ::testing::Test {
/*pzTail=*/nullptr));
struct AdbcSqliteBinder* binder =
this->binder.schema.release ? &this->binder : nullptr;
- ASSERT_THAT(AdbcSqliteExportReader(db, stmt, binder, infer_rows,
- &reader->stream.value, &error),
+ ASSERT_THAT(PrivateAdbcSqliteExportReader(db, stmt, binder, infer_rows,
+ &reader->stream.value, &error),
IsOkStatus(&error));
ASSERT_NO_FATAL_FAILURE(reader->GetSchema());
}
diff --git a/c/driver/sqlite/statement_reader.c b/c/driver/sqlite/statement_reader.c
index 69f90ebd68..fe4adc27d5 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -34,8 +34,8 @@
#include "driver/common/utils.h"
-AdbcStatusCode AdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
+ struct AdbcError* error) {
int status = binder->params.get_schema(&binder->params, &binder->schema);
if (status != 0) {
const char* message = binder->params.get_last_error(&binder->params);
@@ -108,13 +108,13 @@ AdbcStatusCode AdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
return ADBC_STATUS_OK;
}
-AdbcStatusCode AdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
- struct ArrowArrayStream* values,
- struct AdbcError* error) {
- AdbcSqliteBinderRelease(binder);
+AdbcStatusCode PrivateAdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
+ struct ArrowArrayStream* values,
+ struct AdbcError* error) {
+ PrivateAdbcSqliteBinderRelease(binder);
binder->params = *values;
memset(values, 0, sizeof(*values));
- return AdbcSqliteBinderSet(binder, error);
+ return PrivateAdbcSqliteBinderSet(binder, error);
}
#define SECONDS_PER_DAY 86400
@@ -270,9 +270,9 @@ static AdbcStatusCode ArrowTimestampToIsoString(int64_t value, enum ArrowTimeUni
return ADBC_STATUS_OK;
}
-AdbcStatusCode AdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder, sqlite3* conn,
- sqlite3_stmt* stmt, char* finished,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
+ sqlite3* conn, sqlite3_stmt* stmt,
+ char* finished, struct AdbcError* error) {
struct ArrowError arrow_error = {0};
int status = 0;
while (!binder->array.release || binder->next_row >= binder->array.length) {
@@ -300,7 +300,7 @@ AdbcStatusCode AdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder, sqlite3
if (!binder->array.release) {
*finished = 1;
- AdbcSqliteBinderRelease(binder);
+ PrivateAdbcSqliteBinderRelease(binder);
return ADBC_STATUS_OK;
}
@@ -452,7 +452,7 @@ AdbcStatusCode AdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder, sqlite3
return ADBC_STATUS_OK;
}
-void AdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder) {
+void PrivateAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder) {
if (binder->schema.release) {
binder->schema.release(&binder->schema);
}
@@ -660,8 +660,8 @@ int StatementReaderGetNext(struct ArrowArrayStream* self, struct ArrowArray* out
} else {
char finished = 0;
struct AdbcError error = {0};
- status = AdbcSqliteBinderBindNext(reader->binder, reader->db, reader->stmt,
- &finished, &error);
+ status = PrivateAdbcSqliteBinderBindNext(reader->binder, reader->db, reader->stmt,
+ &finished, &error);
if (status != ADBC_STATUS_OK) {
reader->done = 1;
status = EIO;
@@ -736,7 +736,7 @@ void StatementReaderRelease(struct ArrowArrayStream* self) {
free(reader->types);
}
if (reader->binder) {
- AdbcSqliteBinderRelease(reader->binder);
+ PrivateAdbcSqliteBinderRelease(reader->binder);
}
free(self->private_data);
@@ -1125,10 +1125,11 @@ AdbcStatusCode StatementReaderInferOneValue(
return ADBC_STATUS_OK;
} // NOLINT(whitespace/indent)
-AdbcStatusCode AdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
- struct AdbcSqliteBinder* binder, size_t batch_size,
- struct ArrowArrayStream* stream,
- struct AdbcError* error) {
+AdbcStatusCode PrivateAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
+ struct AdbcSqliteBinder* binder,
+ size_t batch_size,
+ struct ArrowArrayStream* stream,
+ struct AdbcError* error) {
struct StatementReader* reader = malloc(sizeof(struct StatementReader));
memset(reader, 0, sizeof(struct StatementReader));
reader->db = db;
@@ -1154,7 +1155,7 @@ AdbcStatusCode AdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
if (binder) {
char finished = 0;
- status = AdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
+ status = PrivateAdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
if (finished) {
reader->done = 1;
}
@@ -1170,7 +1171,7 @@ AdbcStatusCode AdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
break;
} else {
char finished = 0;
- status = AdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
+ status = PrivateAdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
if (status != ADBC_STATUS_OK) break;
if (finished) {
reader->done = 1;
diff --git a/c/driver/sqlite/statement_reader.h b/c/driver/sqlite/statement_reader.h
index 2e6b19086c..e72bf2998f 100644
--- a/c/driver/sqlite/statement_reader.h
+++ b/c/driver/sqlite/statement_reader.h
@@ -41,15 +41,15 @@ struct ADBC_EXPORT AdbcSqliteBinder {
};
ADBC_EXPORT
-AdbcStatusCode AdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
- struct ArrowArrayStream* values,
- struct AdbcError* error);
+AdbcStatusCode PrivateAdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
+ struct ArrowArrayStream* values,
+ struct AdbcError* error);
ADBC_EXPORT
-AdbcStatusCode AdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder, sqlite3* conn,
- sqlite3_stmt* stmt, char* finished,
- struct AdbcError* error);
+AdbcStatusCode PrivateAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
+ sqlite3* conn, sqlite3_stmt* stmt,
+ char* finished, struct AdbcError* error);
ADBC_EXPORT
-void AdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder);
+void PrivateAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder);
/// \brief Initialize an ArrowArrayStream from a sqlite3_stmt.
/// \param[in] db The SQLite connection.
@@ -59,10 +59,11 @@ void AdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder);
/// \param[out] stream The stream to export to.
/// \param[out] error Error details, if needed.
ADBC_EXPORT
-AdbcStatusCode AdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
- struct AdbcSqliteBinder* binder, size_t batch_size,
- struct ArrowArrayStream* stream,
- struct AdbcError* error);
+AdbcStatusCode PrivateAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
+ struct AdbcSqliteBinder* binder,
+ size_t batch_size,
+ struct ArrowArrayStream* stream,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/integration/static_test/CMakeLists.txt b/c/integration/static_test/CMakeLists.txt
new file mode 100644
index 0000000000..e0ada2fe70
--- /dev/null
+++ b/c/integration/static_test/CMakeLists.txt
@@ -0,0 +1,49 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.18)
+
+project(adbc-static-test LANGUAGES C CXX)
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+
+find_package(AdbcDriverCommon REQUIRED)
+find_package(AdbcDriverFramework REQUIRED)
+
+find_package(AdbcDriverBigQuery REQUIRED)
+find_package(AdbcDriverFlightSQL REQUIRED)
+find_package(AdbcDriverPostgreSQL REQUIRED)
+find_package(AdbcDriverSQLite REQUIRED)
+find_package(AdbcDriverSnowflake REQUIRED)
+
+find_package(fmt REQUIRED)
+find_package(nanoarrow REQUIRED)
+
+add_executable(static_test main.c)
+# We need to link the C++ standard library since some of the drivers are
+# written in C++.
+set_target_properties(static_test PROPERTIES LINKER_LANGUAGE CXX)
+target_link_libraries(static_test
+ PRIVATE AdbcDriverFlightSQL::adbc_driver_flightsql_static
+ AdbcDriverPostgreSQL::adbc_driver_postgresql_static
+ AdbcDriverSQLite::adbc_driver_sqlite_static
+ PostgreSQL::PostgreSQL
+ SQLite::SQLite3
+ fmt::fmt
+ nanoarrow::nanoarrow
+ AdbcDriverCommon::adbc_driver_common
+ AdbcDriverFramework::adbc_driver_framework)
diff --git a/c/integration/static_test/README.md b/c/integration/static_test/README.md
new file mode 100644
index 0000000000..1da0f562d2
--- /dev/null
+++ b/c/integration/static_test/README.md
@@ -0,0 +1,23 @@
+
+
+# Static Linking Test
+
+This is only used to test that static linking with multiple drivers behaves as
+expected. See the docker-compose job `cpp-static-test`.
diff --git a/c/integration/static_test/main.c b/c/integration/static_test/main.c
new file mode 100644
index 0000000000..91d0ab0ed8
--- /dev/null
+++ b/c/integration/static_test/main.c
@@ -0,0 +1,78 @@
+// 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
+#include
+#include
+
+#include
+
+AdbcStatusCode FlightSQLDriverInit(int version, void* raw_driver,
+ struct AdbcError* error);
+AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
+ struct AdbcError* error);
+AdbcStatusCode SqliteDriverInit(int version, void* raw_driver, struct AdbcError* error);
+
+int main(int argc, char** argv) {
+ struct AdbcError error;
+
+ struct AdbcDriver flightsql;
+ struct AdbcDriver postgresql;
+ struct AdbcDriver sqlite;
+
+ memset(&error, 0, sizeof(error));
+ memset(&flightsql, 0, sizeof(flightsql));
+ memset(&postgresql, 0, sizeof(postgresql));
+ memset(&sqlite, 0, sizeof(sqlite));
+
+ AdbcStatusCode status;
+
+ status = FlightSQLDriverInit(ADBC_VERSION_1_1_0, &flightsql, &error);
+ if (status != ADBC_STATUS_OK) {
+ if (error.release) {
+ fprintf(stderr, "FlightSQLDriverInit failed: %s\n", error.message);
+ error.release(&error);
+ } else {
+ fprintf(stderr, "FlightSQLDriverInit failed\n");
+ }
+ return EXIT_FAILURE;
+ }
+
+ status = PostgresqlDriverInit(ADBC_VERSION_1_1_0, &postgresql, &error);
+ if (status != ADBC_STATUS_OK) {
+ if (error.release) {
+ fprintf(stderr, "PostgresqlDriverInit failed: %s\n", error.message);
+ error.release(&error);
+ } else {
+ fprintf(stderr, "PostgresqlDriverInit failed\n");
+ }
+ return EXIT_FAILURE;
+ }
+
+ status = SqliteDriverInit(ADBC_VERSION_1_1_0, &sqlite, &error);
+ if (status != ADBC_STATUS_OK) {
+ if (error.release) {
+ fprintf(stderr, "SqliteDriverInit failed: %s\n", error.message);
+ error.release(&error);
+ } else {
+ fprintf(stderr, "SqliteDriverInit failed\n");
+ }
+ return EXIT_FAILURE;
+ }
+
+ return EXIT_SUCCESS;
+}
diff --git a/c/symbols.map b/c/symbols.map
index c9464b2da4..5fc2d1375a 100644
--- a/c/symbols.map
+++ b/c/symbols.map
@@ -19,6 +19,8 @@
global:
# Only expose symbols from the ADBC API
Adbc*;
+ # Needed for tests (unfortunately)
+ PrivateAdbc*;
# Expose driver-specific initialization routines
FlightSQLDriverInit;
diff --git a/c/validation/adbc_validation_connection.cc b/c/validation/adbc_validation_connection.cc
index 0f3c135545..999bcef5b4 100644
--- a/c/validation/adbc_validation_connection.cc
+++ b/c/validation/adbc_validation_connection.cc
@@ -981,13 +981,13 @@ void ConnectionTest::TestMetadataGetObjectsPrimaryKey() {
<< "could not initialize the AdbcGetObjectsData object";
// Test primary key
- struct AdbcGetObjectsTable* table =
- AdbcGetObjectsDataGetTableByName(*get_objects_data, quirks()->catalog().c_str(),
- quirks()->db_schema().c_str(), "adbc_pkey_test");
+ struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ *get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
+ "adbc_pkey_test");
ASSERT_NE(table, nullptr) << "could not find adbc_pkey_test table";
ASSERT_EQ(table->n_table_columns, 1);
- struct AdbcGetObjectsColumn* column = AdbcGetObjectsDataGetColumnByName(
+ struct AdbcGetObjectsColumn* column = PrivateAdbcGetObjectsDataGetColumnByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_pkey_test", "id");
ASSERT_NE(column, nullptr) << "could not find id column on adbc_pkey_test table";
@@ -1000,7 +1000,7 @@ void ConnectionTest::TestMetadataGetObjectsPrimaryKey() {
ConstraintTest(constraint, "PRIMARY KEY", {"id"});
// Test composite primary key
- struct AdbcGetObjectsTable* composite_table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* composite_table = PrivateAdbcGetObjectsDataGetTableByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_composite_pkey_test");
ASSERT_NE(composite_table, nullptr) << "could not find adbc_composite_pkey_test table";
@@ -1013,7 +1013,7 @@ void ConnectionTest::TestMetadataGetObjectsPrimaryKey() {
const char* parent_2_column_names[2] = {"id_primary_col1", "id_primary_col2"};
struct AdbcGetObjectsColumn* parent_2_column;
for (int column_name_index = 0; column_name_index < 2; column_name_index++) {
- parent_2_column = AdbcGetObjectsDataGetColumnByName(
+ parent_2_column = PrivateAdbcGetObjectsDataGetColumnByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_composite_pkey_test", parent_2_column_names[column_name_index]);
ASSERT_NE(parent_2_column, nullptr)
@@ -1104,7 +1104,7 @@ void ConnectionTest::TestMetadataGetObjectsForeignKey() {
<< "could not initialize the AdbcGetObjectsData object";
// Test child table
- struct AdbcGetObjectsTable* child_table = AdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* child_table = PrivateAdbcGetObjectsDataGetTableByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_fkey_child_test");
ASSERT_NE(child_table, nullptr) << "could not find adbc_fkey_child_test table";
@@ -1115,7 +1115,7 @@ void ConnectionTest::TestMetadataGetObjectsForeignKey() {
const char* child_column_names[3] = {"id_child_col1", "id_child_col2", "id_child_col3"};
struct AdbcGetObjectsColumn* child_column;
for (int column_index = 0; column_index < 2; column_index++) {
- child_column = AdbcGetObjectsDataGetColumnByName(
+ child_column = PrivateAdbcGetObjectsDataGetColumnByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_fkey_child_test", child_column_names[column_index]);
ASSERT_NE(child_column, nullptr)
diff --git a/c/validation/adbc_validation_util.h b/c/validation/adbc_validation_util.h
index b4f5d6f81a..00091dcc97 100644
--- a/c/validation/adbc_validation_util.h
+++ b/c/validation/adbc_validation_util.h
@@ -242,9 +242,9 @@ struct StreamReader {
struct GetObjectsReader {
explicit GetObjectsReader(struct ArrowArrayView* array_view) {
// TODO: this swallows any construction errors
- get_objects_data_ = AdbcGetObjectsDataInit(array_view);
+ get_objects_data_ = PrivateAdbcGetObjectsDataInit(array_view);
}
- ~GetObjectsReader() { AdbcGetObjectsDataDelete(get_objects_data_); }
+ ~GetObjectsReader() { PrivateAdbcGetObjectsDataDelete(get_objects_data_); }
struct AdbcGetObjectsData* operator*() { return get_objects_data_; }
struct AdbcGetObjectsData* operator->() { return get_objects_data_; }
diff --git a/ci/scripts/cpp_static_test.sh b/ci/scripts/cpp_static_test.sh
new file mode 100755
index 0000000000..d86cde334e
--- /dev/null
+++ b/ci/scripts/cpp_static_test.sh
@@ -0,0 +1,123 @@
+#!/usr/bin/env bash
+# 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.
+
+# Test building a simple application using the static drivers, ensuring that
+# symbols do not clash and all dependencies are present.
+# https://github.com/apache/arrow-adbc/issues/2562
+
+set -euo pipefail
+
+main() {
+ local -r source_dir="${1}"
+ local -r build_dir="${2}"
+ local -r install_dir="${3}"
+
+ mkdir -p "${build_dir}"
+
+ echo "Install fmt"
+ if [ ! -d "${build_dir}/fmt" ]; then
+ git clone https://github.com/fmtlib/fmt.git --branch 11.1.4 --depth 1 "${build_dir}/fmt"
+ fi
+ mkdir -p "${build_dir}/fmt/build"
+ pushd "${build_dir}/fmt/build"
+ cmake "${build_dir}/fmt" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="${install_dir}" \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE \
+ -DFMT_DOC=OFF \
+ -DFMT_TEST=OFF
+ cmake --build "${build_dir}/fmt/build" --target install -j
+ popd
+
+ echo "Install nanoarrow"
+ if [ ! -d "${build_dir}/nanoarrow" ]; then
+ git clone https://github.com/apache/arrow-nanoarrow.git --depth 1 "${build_dir}/nanoarrow"
+ fi
+ mkdir -p "${build_dir}/nanoarrow/build"
+ pushd "${build_dir}/nanoarrow/build"
+ cmake "${build_dir}/nanoarrow" \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_INSTALL_PREFIX="${install_dir}" \
+ -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE
+ cmake --build "${build_dir}/nanoarrow/build" --target install -j
+ popd
+
+ echo "Install ADBC"
+ mkdir -p "${build_dir}/install"
+ pushd "${build_dir}/install"
+ env \
+ ADBC_BUILD_SHARED=OFF \
+ ADBC_BUILD_STATIC=ON \
+ ADBC_BUILD_TESTS=OFF \
+ ADBC_USE_ASAN=OFF \
+ ADBC_USE_UBSAN=OFF \
+ ADBC_CMAKE_ARGS="-DADBC_WITH_VENDORED_FMT=OFF -DADBC_WITH_VENDORED_NANOARROW=OFF -DADBC_DEFINE_COMMON_ENTRYPOINTS=OFF" \
+ "${source_dir}/ci/scripts/cpp_build.sh" \
+ "${source_dir}" \
+ "${build_dir}/install" \
+ "${install_dir}"
+ popd
+
+ # No shared libraries should exist
+ if find "${install_dir}" | grep -E "libadbc.*\.so"; then
+ echo "Found ADBC shared libraries, which should not exist for this test"
+ return 1
+ fi
+
+ # Make sure Adbc symbols aren't exported
+ failed=0
+ for lib in "${install_dir}/lib"/libadbc_driver_*.a; do
+ echo "Checking symbols in $lib"
+ if [[ $(basename "$lib") == *"adbc_driver_manager"* ]]; then
+ continue
+ fi
+
+ nm \
+ --defined-only \
+ --demangle \
+ --extern-only \
+ --no-weak \
+ "${lib}" | \
+ grep ' T ' | \
+ awk '{print $3}' | \
+ { grep --extended-regexp '^Adbc' || true; } | \
+ { grep --extended-regexp --invert-match '^AdbcDriver[a-zA-Z]+Init' || true; } \
+ > /tmp/symbols.txt
+ if [[ -s /tmp/symbols.txt ]]; then
+ echo "Found unexpected exported Adbc* symbols in $lib"
+ cat /tmp/symbols.txt
+ failed=$(($failed + 1))
+ fi
+ done
+ if [[ $failed -ne 0 ]]; then
+ return $failed
+ fi
+
+ echo "Build test application"
+ mkdir -p "${build_dir}/test"
+ pushd "${build_dir}/test"
+ cmake "${source_dir}/c/integration/static_test" \
+ -DCMAKE_PREFIX_PATH="${install_dir}" \
+ -DCMAKE_VERBOSE_MAKEFILE=ON
+ cmake --build "${build_dir}" --target static_test
+
+ "${build_dir}/static_test"
+ popd
+}
+
+main "$@"
diff --git a/compose.yaml b/compose.yaml
index 742669cc80..26dac01c0d 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -34,6 +34,7 @@ services:
# Build/test with latest Clang
cpp-clang-latest:
+ image: ${REPO}:${ARCH}-cpp-clang-latest-adbc
build:
context: .
dockerfile: ci/docker/cpp-clang-latest.dockerfile
@@ -44,6 +45,7 @@ services:
command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_build.sh /adbc /adbc/build/clang-latest && env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 BUILD_DRIVER_SQLITE=1 /adbc/ci/scripts/cpp_test.sh /adbc/build/clang-latest'"
cpp-gcc-latest:
+ image: ${REPO}:${ARCH}-cpp-gcc-latest-adbc
build:
context: .
dockerfile: ci/docker/cpp-gcc-latest.dockerfile
@@ -54,6 +56,14 @@ services:
- .:/adbc:delegated
command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_build.sh /adbc /adbc/build/gcc-latest && env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 BUILD_DRIVER_SQLITE=1 /adbc/ci/scripts/cpp_test.sh /adbc/build/gcc-latest'"
+ # Test building and installing the static libraries, then try linking to them.
+ cpp-static-test:
+ image: ${REPO}:${ARCH}-cpp-clang-latest-adbc
+ volumes:
+ - .:/adbc:delegated
+ command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_static_test.sh /adbc /adbc/build/static-test /adbc/build/local'"
+
+
############################ Documentation ###################################
docs:
diff --git a/docs/source/cpp/index.rst b/docs/source/cpp/index.rst
index 29bbfc9202..6f68c9e53a 100644
--- a/docs/source/cpp/index.rst
+++ b/docs/source/cpp/index.rst
@@ -26,4 +26,5 @@ C and C++
driver_manager
concurrency
driver_example
+ static_linking
api/index
diff --git a/docs/source/cpp/static_linking.rst b/docs/source/cpp/static_linking.rst
new file mode 100644
index 0000000000..19470ad066
--- /dev/null
+++ b/docs/source/cpp/static_linking.rst
@@ -0,0 +1,64 @@
+.. 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.
+
+==============
+Static Linking
+==============
+
+To statically link and use *multiple* drivers, the following limitations hold:
+
+#. You must build with these CMake options [#meson]_:
+
+ - ``-DADBC_BUILD_STATIC=ON``
+ - ``-DADBC_DEFINE_COMMON_ENTRYPOINTS=OFF``
+ - ``-DADBC_WITH_VENDORED_FMT=OFF``
+ - ``-DADBC_WITH_VENDORED_NANOARROW=OFF``
+
+#. You must provide ``fmt`` and ``nanoarrow`` dependencies. (This may be
+ relaxed in the future.)
+#. You must explicitly link all the required transitive dependencies. This
+ is:
+
+ - ``libpq`` for PostgreSQL
+ - ``sqlite3`` for SQLite
+ - ``adbc_driver_common``, ``adbc_driver_framework``, ``fmt``,
+ ``nanoarrow``, and the C++ standard library for either PostgreSQL or
+ SQLite.
+ - To link the C++ standard library, the easiest thing is to just use the
+ C++ linker, even if the code itself is in C, e.g.
+
+ .. code-block:: cmake
+
+ set_target_properties(myapp PROPERTIES LINKER_LANGUAGE CXX)
+
+ - Go-based drivers (BigQuery, Flight SQL, Snowflake) have no transitive
+ dependencies.
+
+#. You cannot link more than a single Go-based driver. See `golang/go#20639
+ `_, `StackOverflow #67243572 `_, and `StackOverflow
+ #34333107 `_ for a discussion of the issues involved. (This
+ may be relaxed in the future by providing a way to build a single driver
+ library with all driver implementations included.)
+
+An example of this can be seen with ``cpp_static_test.sh`` and
+``c/integration/static_test`` in the source tree.
+
+.. [#meson] There is currently no documentation for Meson, but in principle
+ it should work similarly.
+.. _go20639: https://github.com/golang/go/issues/20639
+.. _so67243572: https://stackoverflow.com/questions/67243572/go-cgo-produce-static-library-without-definitions-of-go-runtime-functions
+.. _so34333107: https://stackoverflow.com/questions/34333107/is-there-a-way-to-include-multiple-c-archive-packages-in-a-single-binary
diff --git a/go/adbc/pkg/_tmpl/utils.c.tmpl b/go/adbc/pkg/_tmpl/utils.c.tmpl
index 3b7601a6c8..b941f2224a 100644
--- a/go/adbc/pkg/_tmpl/utils.c.tmpl
+++ b/go/adbc/pkg/_tmpl/utils.c.tmpl
@@ -83,6 +83,7 @@ struct AdbcErrorDetail {{.Prefix}}ErrorGetDetail(const struct AdbcError* error,
};
}
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
int AdbcErrorGetDetailCount(const struct AdbcError* error) {
return {{.Prefix}}ErrorGetDetailCount(error);
}
@@ -430,6 +431,7 @@ ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
return {{.Prefix}}DriverInit(version, driver, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
int {{.Prefix}}ArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int {{.Prefix}}ArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
diff --git a/go/adbc/pkg/bigquery/utils.c b/go/adbc/pkg/bigquery/utils.c
index 3fefb3f5e2..e5f97ca7a0 100644
--- a/go/adbc/pkg/bigquery/utils.c
+++ b/go/adbc/pkg/bigquery/utils.c
@@ -85,6 +85,7 @@ struct AdbcErrorDetail BigQueryErrorGetDetail(const struct AdbcError* error,
};
}
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
int AdbcErrorGetDetailCount(const struct AdbcError* error) {
return BigQueryErrorGetDetailCount(error);
}
@@ -432,6 +433,7 @@ ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
return BigQueryDriverInit(version, driver, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
int BigQueryArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int BigQueryArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
diff --git a/go/adbc/pkg/flightsql/utils.c b/go/adbc/pkg/flightsql/utils.c
index a3aa1dd370..46cc5d2d85 100644
--- a/go/adbc/pkg/flightsql/utils.c
+++ b/go/adbc/pkg/flightsql/utils.c
@@ -85,6 +85,7 @@ struct AdbcErrorDetail FlightSQLErrorGetDetail(const struct AdbcError* error,
};
}
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
int AdbcErrorGetDetailCount(const struct AdbcError* error) {
return FlightSQLErrorGetDetailCount(error);
}
@@ -432,6 +433,7 @@ ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
return FlightSQLDriverInit(version, driver, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
int FlightSQLArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int FlightSQLArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
diff --git a/go/adbc/pkg/snowflake/utils.c b/go/adbc/pkg/snowflake/utils.c
index 17ef6a4ff3..67ae1046db 100644
--- a/go/adbc/pkg/snowflake/utils.c
+++ b/go/adbc/pkg/snowflake/utils.c
@@ -85,6 +85,7 @@ struct AdbcErrorDetail SnowflakeErrorGetDetail(const struct AdbcError* error,
};
}
+#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
int AdbcErrorGetDetailCount(const struct AdbcError* error) {
return SnowflakeErrorGetDetailCount(error);
}
@@ -432,6 +433,7 @@ ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
return SnowflakeDriverInit(version, driver, error);
}
+#endif // ADBC_NO_COMMON_ENTRYPOINTS
int SnowflakeArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int SnowflakeArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
From 34f66d94222ed501c88dc0b276a22ed7aca5b14f Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 10:03:51 +0900
Subject: [PATCH 02/16] PrivateAdbc -> InternalAdbc
---
c/driver/common/utils.c | 52 +++++++++++-----------
c/driver/common/utils.h | 16 +++----
c/driver/common/utils_test.cc | 42 ++++++++---------
c/driver/postgresql/postgresql_test.cc | 22 ++++-----
c/driver/postgresql/statement.cc | 6 +--
c/driver/sqlite/sqlite.cc | 20 ++++-----
c/driver/sqlite/sqlite_test.cc | 8 ++--
c/driver/sqlite/statement_reader.c | 44 +++++++++---------
c/driver/sqlite/statement_reader.h | 24 +++++-----
c/symbols.map | 4 +-
c/validation/adbc_validation_connection.cc | 12 ++---
c/validation/adbc_validation_util.h | 4 +-
12 files changed, 127 insertions(+), 127 deletions(-)
diff --git a/c/driver/common/utils.c b/c/driver/common/utils.c
index 1b05429a64..dd9291eb9f 100644
--- a/c/driver/common/utils.c
+++ b/c/driver/common/utils.c
@@ -27,7 +27,7 @@
static size_t kErrorBufferSize = 1024;
-int PrivateAdbcStatusCodeToErrno(AdbcStatusCode code) {
+int InternalAdbcStatusCodeToErrno(AdbcStatusCode code) {
switch (code) {
case ADBC_STATUS_OK:
return 0;
@@ -285,9 +285,9 @@ void StringBuilderReset(struct StringBuilder* builder) {
memset(builder, 0, sizeof(*builder));
}
-AdbcStatusCode PrivateAdbcInitConnectionGetInfoSchema(struct ArrowSchema* schema,
- struct ArrowArray* array,
- struct AdbcError* error) {
+AdbcStatusCode InternalAdbcInitConnectionGetInfoSchema(struct ArrowSchema* schema,
+ struct ArrowArray* array,
+ struct AdbcError* error) {
// TODO: use C equivalent of UniqueSchema to avoid incomplete schema
// on error
ArrowSchemaInit(schema);
@@ -351,10 +351,10 @@ AdbcStatusCode PrivateAdbcInitConnectionGetInfoSchema(struct ArrowSchema* schema
return ADBC_STATUS_OK;
} // NOLINT(whitespace/indent)
-AdbcStatusCode PrivateAdbcConnectionGetInfoAppendString(struct ArrowArray* array,
- uint32_t info_code,
- const char* info_value,
- struct AdbcError* error) {
+AdbcStatusCode InternalAdbcConnectionGetInfoAppendString(struct ArrowArray* array,
+ uint32_t info_code,
+ const char* info_value,
+ struct AdbcError* error) {
CHECK_NA(INTERNAL, ArrowArrayAppendUInt(array->children[0], info_code), error);
// Append to type variant
struct ArrowStringView value = ArrowCharView(info_value);
@@ -366,10 +366,10 @@ AdbcStatusCode PrivateAdbcConnectionGetInfoAppendString(struct ArrowArray* array
return ADBC_STATUS_OK;
}
-AdbcStatusCode PrivateAdbcConnectionGetInfoAppendInt(struct ArrowArray* array,
- uint32_t info_code,
- int64_t info_value,
- struct AdbcError* error) {
+AdbcStatusCode InternalAdbcConnectionGetInfoAppendInt(struct ArrowArray* array,
+ uint32_t info_code,
+ int64_t info_value,
+ struct AdbcError* error) {
CHECK_NA(INTERNAL, ArrowArrayAppendUInt(array->children[0], info_code), error);
// Append to type variant
CHECK_NA(INTERNAL, ArrowArrayAppendInt(array->children[1]->children[2], info_value),
@@ -380,8 +380,8 @@ AdbcStatusCode PrivateAdbcConnectionGetInfoAppendInt(struct ArrowArray* array,
return ADBC_STATUS_OK;
}
-AdbcStatusCode PrivateAdbcInitConnectionObjectsSchema(struct ArrowSchema* schema,
- struct AdbcError* error) {
+AdbcStatusCode InternalAdbcInitConnectionObjectsSchema(struct ArrowSchema* schema,
+ struct AdbcError* error) {
ArrowSchemaInit(schema);
CHECK_NA(INTERNAL, ArrowSchemaSetTypeStruct(schema, /*num_columns=*/2), error);
CHECK_NA(INTERNAL, ArrowSchemaSetType(schema->children[0], NANOARROW_TYPE_STRING),
@@ -564,7 +564,7 @@ AdbcStatusCode PrivateAdbcInitConnectionObjectsSchema(struct ArrowSchema* schema
return ADBC_STATUS_OK;
}
-struct AdbcGetObjectsData* PrivateAdbcGetObjectsDataInit(
+struct AdbcGetObjectsData* InternalAdbcGetObjectsDataInit(
struct ArrowArrayView* array_view) {
struct AdbcGetObjectsData* get_objects_data =
(struct AdbcGetObjectsData*)calloc(1, sizeof(struct AdbcGetObjectsData));
@@ -897,11 +897,11 @@ struct AdbcGetObjectsData* PrivateAdbcGetObjectsDataInit(
return get_objects_data;
error_handler:
- PrivateAdbcGetObjectsDataDelete(get_objects_data);
+ InternalAdbcGetObjectsDataDelete(get_objects_data);
return NULL;
}
-void PrivateAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data) {
+void InternalAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data) {
for (int64_t catalog_index = 0; catalog_index < get_objects_data->n_catalogs;
catalog_index++) {
struct AdbcGetObjectsCatalog* catalog = get_objects_data->catalogs[catalog_index];
@@ -948,7 +948,7 @@ void PrivateAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data
free(get_objects_data);
}
-struct AdbcGetObjectsCatalog* PrivateAdbcGetObjectsDataGetCatalogByName(
+struct AdbcGetObjectsCatalog* InternalAdbcGetObjectsDataGetCatalogByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name) {
if (catalog_name != NULL) {
for (int64_t i = 0; i < get_objects_data->n_catalogs; i++) {
@@ -962,12 +962,12 @@ struct AdbcGetObjectsCatalog* PrivateAdbcGetObjectsDataGetCatalogByName(
return NULL;
}
-struct AdbcGetObjectsSchema* PrivateAdbcGetObjectsDataGetSchemaByName(
+struct AdbcGetObjectsSchema* InternalAdbcGetObjectsDataGetSchemaByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name) {
if (schema_name != NULL) {
struct AdbcGetObjectsCatalog* catalog =
- PrivateAdbcGetObjectsDataGetCatalogByName(get_objects_data, catalog_name);
+ InternalAdbcGetObjectsDataGetCatalogByName(get_objects_data, catalog_name);
if (catalog != NULL) {
for (int64_t i = 0; i < catalog->n_db_schemas; i++) {
struct AdbcGetObjectsSchema* schema = catalog->catalog_db_schemas[i];
@@ -981,11 +981,11 @@ struct AdbcGetObjectsSchema* PrivateAdbcGetObjectsDataGetSchemaByName(
return NULL;
}
-struct AdbcGetObjectsTable* PrivateAdbcGetObjectsDataGetTableByName(
+struct AdbcGetObjectsTable* InternalAdbcGetObjectsDataGetTableByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name) {
if (table_name != NULL) {
- struct AdbcGetObjectsSchema* schema = PrivateAdbcGetObjectsDataGetSchemaByName(
+ struct AdbcGetObjectsSchema* schema = InternalAdbcGetObjectsDataGetSchemaByName(
get_objects_data, catalog_name, schema_name);
if (schema != NULL) {
for (int64_t i = 0; i < schema->n_db_schema_tables; i++) {
@@ -1000,12 +1000,12 @@ struct AdbcGetObjectsTable* PrivateAdbcGetObjectsDataGetTableByName(
return NULL;
}
-struct AdbcGetObjectsColumn* PrivateAdbcGetObjectsDataGetColumnByName(
+struct AdbcGetObjectsColumn* InternalAdbcGetObjectsDataGetColumnByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const column_name) {
if (column_name != NULL) {
- struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = InternalAdbcGetObjectsDataGetTableByName(
get_objects_data, catalog_name, schema_name, table_name);
if (table != NULL) {
for (int64_t i = 0; i < table->n_table_columns; i++) {
@@ -1020,12 +1020,12 @@ struct AdbcGetObjectsColumn* PrivateAdbcGetObjectsDataGetColumnByName(
return NULL;
}
-struct AdbcGetObjectsConstraint* PrivateAdbcGetObjectsDataGetConstraintByName(
+struct AdbcGetObjectsConstraint* InternalAdbcGetObjectsDataGetConstraintByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const constraint_name) {
if (constraint_name != NULL) {
- struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = InternalAdbcGetObjectsDataGetTableByName(
get_objects_data, catalog_name, schema_name, table_name);
if (table != NULL) {
for (int64_t i = 0; i < table->n_table_constraints; i++) {
diff --git a/c/driver/common/utils.h b/c/driver/common/utils.h
index 5872c12960..b4fd476863 100644
--- a/c/driver/common/utils.h
+++ b/c/driver/common/utils.h
@@ -29,7 +29,7 @@
extern "C" {
#endif
-int PrivateAdbcStatusCodeToErrno(AdbcStatusCode code);
+int InternalAdbcStatusCodeToErrno(AdbcStatusCode code);
// If using mingw's c99-compliant printf, we need a different format-checking attribute
#if defined(__USE_MINGW_ANSI_STDIO) && defined(__MINGW_PRINTF_FORMAT)
@@ -217,25 +217,25 @@ struct AdbcGetObjectsData {
// does not copy any data from array
// returns NULL on error
-struct AdbcGetObjectsData* PrivateAdbcGetObjectsDataInit(
+struct AdbcGetObjectsData* InternalAdbcGetObjectsDataInit(
struct ArrowArrayView* array_view);
-void PrivateAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data);
+void InternalAdbcGetObjectsDataDelete(struct AdbcGetObjectsData* get_objects_data);
// returns NULL on error
// for now all arguments are required
-struct AdbcGetObjectsCatalog* PrivateAdbcGetObjectsDataGetCatalogByName(
+struct AdbcGetObjectsCatalog* InternalAdbcGetObjectsDataGetCatalogByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name);
-struct AdbcGetObjectsSchema* PrivateAdbcGetObjectsDataGetSchemaByName(
+struct AdbcGetObjectsSchema* InternalAdbcGetObjectsDataGetSchemaByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name);
-struct AdbcGetObjectsTable* PrivateAdbcGetObjectsDataGetTableByName(
+struct AdbcGetObjectsTable* InternalAdbcGetObjectsDataGetTableByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name);
-struct AdbcGetObjectsColumn* PrivateAdbcGetObjectsDataGetColumnByName(
+struct AdbcGetObjectsColumn* InternalAdbcGetObjectsDataGetColumnByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const column_name);
-struct AdbcGetObjectsConstraint* PrivateAdbcGetObjectsDataGetConstraintByName(
+struct AdbcGetObjectsConstraint* InternalAdbcGetObjectsDataGetConstraintByName(
struct AdbcGetObjectsData* get_objects_data, const char* const catalog_name,
const char* const schema_name, const char* const table_name,
const char* const constraint_name);
diff --git a/c/driver/common/utils_test.cc b/c/driver/common/utils_test.cc
index 07dbcb7620..3e44765d1f 100644
--- a/c/driver/common/utils_test.cc
+++ b/c/driver/common/utils_test.cc
@@ -209,45 +209,45 @@ TEST(AdbcGetObjectsData, GetObjectsByName) {
mock_table.table_constraints = constraints;
mock_table.n_table_constraints = 2;
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
- "mock_schema", "table"),
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
+ "mock_schema", "table"),
&mock_table);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
- "mock_schema", "table_suffix"),
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
+ "mock_schema", "table_suffix"),
&mock_table_suffix);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
- "mock_schema", "nonexistent"),
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetTableByName(&mock_data, "mock_catalog",
+ "mock_schema", "nonexistent"),
nullptr);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetCatalogByName(&mock_data, "mock_catalog"),
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetCatalogByName(&mock_data, "mock_catalog"),
&mock_catalog);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetCatalogByName(&mock_data, "nonexistent"),
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetCatalogByName(&mock_data, "nonexistent"),
nullptr);
- EXPECT_EQ(
- PrivateAdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog", "mock_schema"),
- &mock_schema);
- EXPECT_EQ(
- PrivateAdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog", "nonexistent"),
- nullptr);
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog",
+ "mock_schema"),
+ &mock_schema);
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetSchemaByName(&mock_data, "mock_catalog",
+ "nonexistent"),
+ nullptr);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetColumnByName(&mock_data, "mock_catalog",
- "mock_schema", "table", "column"),
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetColumnByName(&mock_data, "mock_catalog",
+ "mock_schema", "table", "column"),
&mock_column);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetColumnByName(
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetColumnByName(
&mock_data, "mock_catalog", "mock_schema", "table", "column_suffix"),
&mock_column_suffix);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetColumnByName(
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetColumnByName(
&mock_data, "mock_catalog", "mock_schema", "table", "nonexistent"),
nullptr);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetConstraintByName(
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetConstraintByName(
&mock_data, "mock_catalog", "mock_schema", "table", "constraint"),
&mock_constraint);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetConstraintByName(
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetConstraintByName(
&mock_data, "mock_catalog", "mock_schema", "table", "constraint_suffix"),
&mock_constraint_suffix);
- EXPECT_EQ(PrivateAdbcGetObjectsDataGetConstraintByName(
+ EXPECT_EQ(InternalAdbcGetObjectsDataGetConstraintByName(
&mock_data, "mock_catalog", "mock_schema", "table", "nonexistent"),
nullptr);
}
diff --git a/c/driver/postgresql/postgresql_test.cc b/c/driver/postgresql/postgresql_test.cc
index 3cec988cfd..f37bb6eba5 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -343,7 +343,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetCatalogs) {
auto catalogs = {"postgres", "template0", "template1"};
for (auto catalog : catalogs) {
struct AdbcGetObjectsCatalog* cat =
- PrivateAdbcGetObjectsDataGetCatalogByName(*get_objects_data, catalog);
+ InternalAdbcGetObjectsDataGetCatalogByName(*get_objects_data, catalog);
ASSERT_NE(cat, nullptr) << "catalog " << catalog << " not found";
}
}
@@ -367,7 +367,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetDbSchemas) {
<< "could not initialize the AdbcGetObjectsData object";
struct AdbcGetObjectsSchema* schema =
- PrivateAdbcGetObjectsDataGetSchemaByName(*get_objects_data, "postgres", "public");
+ InternalAdbcGetObjectsDataGetSchemaByName(*get_objects_data, "postgres", "public");
ASSERT_NE(schema, nullptr) << "schema public not found";
}
@@ -411,12 +411,12 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsPrimaryKey) {
ASSERT_NE(*get_objects_data, nullptr)
<< "could not initialize the AdbcGetObjectsData object";
- struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_pkey_test");
ASSERT_NE(table, nullptr) << "could not find adbc_pkey_test table";
ASSERT_EQ(table->n_table_columns, 2);
- struct AdbcGetObjectsColumn* column = PrivateAdbcGetObjectsDataGetColumnByName(
+ struct AdbcGetObjectsColumn* column = InternalAdbcGetObjectsDataGetColumnByName(
*get_objects_data, "postgres", "public", "adbc_pkey_test", "id");
ASSERT_NE(column, nullptr) << "could not find id column on adbc_pkey_test table";
@@ -425,9 +425,9 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsPrimaryKey) {
<< table->n_table_constraints;
struct AdbcGetObjectsConstraint* constraint =
- PrivateAdbcGetObjectsDataGetConstraintByName(*get_objects_data, "postgres",
- "public", "adbc_pkey_test",
- "adbc_pkey_test_pkey");
+ InternalAdbcGetObjectsDataGetConstraintByName(*get_objects_data, "postgres",
+ "public", "adbc_pkey_test",
+ "adbc_pkey_test_pkey");
ASSERT_NE(constraint, nullptr) << "could not find adbc_pkey_test_pkey constraint";
auto constraint_type = std::string(constraint->constraint_type.data,
@@ -505,7 +505,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsForeignKey) {
ASSERT_NE(*get_objects_data, nullptr)
<< "could not initialize the AdbcGetInfoData object";
- struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_fkey_test");
ASSERT_NE(table, nullptr) << "could not find adbc_fkey_test table";
ASSERT_EQ(table->n_table_constraints, 1)
@@ -516,7 +516,7 @@ TEST_F(PostgresConnectionTest, GetObjectsGetAllFindsForeignKey) {
const std::string search_name =
version < "120000" ? "adbc_fkey_test_fid1_fkey" : "adbc_fkey_test_fid1_fid2_fkey";
struct AdbcGetObjectsConstraint* constraint =
- PrivateAdbcGetObjectsDataGetConstraintByName(
+ InternalAdbcGetObjectsDataGetConstraintByName(
*get_objects_data, "postgres", "public", "adbc_fkey_test", search_name.c_str());
ASSERT_NE(constraint, nullptr) << "could not find " << search_name << " constraint";
@@ -618,11 +618,11 @@ TEST_F(PostgresConnectionTest, GetObjectsTableTypesFilter) {
ASSERT_NE(*get_objects_data, nullptr)
<< "could not initialize the AdbcGetInfoData object";
- struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_table_types_table_test");
ASSERT_EQ(table, nullptr) << "unexpected table adbc_table_types_table_test found";
- struct AdbcGetObjectsTable* view = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* view = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, "postgres", "public", "adbc_table_types_view_test");
ASSERT_NE(view, nullptr) << "did not find view adbc_table_types_view_test";
}
diff --git a/c/driver/postgresql/statement.cc b/c/driver/postgresql/statement.cc
index 444d8b35c7..5879e9de71 100644
--- a/c/driver/postgresql/statement.cc
+++ b/c/driver/postgresql/statement.cc
@@ -59,7 +59,7 @@ int TupleReader::GetSchema(struct ArrowSchema* out) {
if (out->release == nullptr) {
SetError(&error_, "[libpq] Result set was already consumed or freed");
status_ = ADBC_STATUS_INVALID_STATE;
- return PrivateAdbcStatusCodeToErrno(status_);
+ return InternalAdbcStatusCodeToErrno(status_);
} else if (na_res != NANOARROW_OK) {
// e.g., Can't allocate memory
SetError(&error_, "[libpq] Error copying schema");
@@ -82,7 +82,7 @@ int TupleReader::GetCopyData() {
if (get_copy_res == -2) {
SetError(&error_, "[libpq] PQgetCopyData() failed: %s", PQerrorMessage(conn_));
status_ = ADBC_STATUS_IO;
- return PrivateAdbcStatusCodeToErrno(status_);
+ return InternalAdbcStatusCodeToErrno(status_);
}
if (get_copy_res == -1) {
@@ -93,7 +93,7 @@ int TupleReader::GetCopyData() {
if (pq_status != PGRES_COMMAND_OK) {
status_ = SetError(&error_, result_, "[libpq] Execution error [%s]: %s",
PQresStatus(pq_status), PQresultErrorMessage(result_));
- return PrivateAdbcStatusCodeToErrno(status_);
+ return InternalAdbcStatusCodeToErrno(status_);
} else {
return ENODATA;
}
diff --git a/c/driver/sqlite/sqlite.cc b/c/driver/sqlite/sqlite.cc
index 5656f0337c..1a47a4f139 100644
--- a/c/driver/sqlite/sqlite.cc
+++ b/c/driver/sqlite/sqlite.cc
@@ -600,8 +600,8 @@ class SqliteConnection : public driver::Connection {
nanoarrow::UniqueArrayStream stream;
struct AdbcError error = ADBC_ERROR_INIT;
AdbcStatusCode status =
- PrivateAdbcSqliteExportReader(conn_, stmt, /*binder=*/NULL,
- /*batch_size=*/64, stream.get(), &error);
+ InternalAdbcSqliteExportReader(conn_, stmt, /*binder=*/NULL,
+ /*batch_size=*/64, stream.get(), &error);
if (status == ADBC_STATUS_OK) {
int code = stream->get_schema(stream.get(), schema);
if (code != 0) {
@@ -767,7 +767,7 @@ class SqliteStatement : public driver::Statement {
if (bind_parameters_.release) {
struct AdbcError error = ADBC_ERROR_INIT;
if (AdbcStatusCode code =
- PrivateAdbcSqliteBinderSetArrayStream(&binder_, &bind_parameters_, &error);
+ InternalAdbcSqliteBinderSetArrayStream(&binder_, &bind_parameters_, &error);
code != ADBC_STATUS_OK) {
return Status::FromAdbc(code, error);
}
@@ -939,7 +939,7 @@ class SqliteStatement : public driver::Statement {
while (true) {
char finished = 0;
status_code =
- PrivateAdbcSqliteBinderBindNext(&binder_, conn_, stmt, &finished, &error);
+ InternalAdbcSqliteBinderBindNext(&binder_, conn_, stmt, &finished, &error);
if (status_code != ADBC_STATUS_OK || finished) {
status = Status::FromAdbc(status_code, error);
break;
@@ -984,7 +984,7 @@ class SqliteStatement : public driver::Statement {
"parameter count mismatch: expected {} but found {}", expected, actual);
}
- auto status = PrivateAdbcSqliteExportReader(
+ auto status = InternalAdbcSqliteExportReader(
conn_, stmt_, binder_.schema.release ? &binder_ : nullptr, batch_size_, stream,
&error);
if (status != ADBC_STATUS_OK) {
@@ -1021,10 +1021,10 @@ class SqliteStatement : public driver::Statement {
if (binder_.schema.release) {
char finished = 0;
struct AdbcError error = ADBC_ERROR_INIT;
- if (AdbcStatusCode code = PrivateAdbcSqliteBinderBindNext(&binder_, conn_, stmt_,
- &finished, &error);
+ if (AdbcStatusCode code = InternalAdbcSqliteBinderBindNext(&binder_, conn_, stmt_,
+ &finished, &error);
code != ADBC_STATUS_OK) {
- PrivateAdbcSqliteBinderRelease(&binder_);
+ InternalAdbcSqliteBinderRelease(&binder_);
return Status::FromAdbc(code, error);
} else if (finished != 0) {
break;
@@ -1041,7 +1041,7 @@ class SqliteStatement : public driver::Statement {
if (!binder_.schema.release) break;
}
- PrivateAdbcSqliteBinderRelease(&binder_);
+ InternalAdbcSqliteBinderRelease(&binder_);
if (sqlite3_reset(stmt_) != SQLITE_OK) {
const char* msg = sqlite3_errmsg(conn_);
@@ -1128,7 +1128,7 @@ class SqliteStatement : public driver::Statement {
rc, sqlite3_errmsg(conn_));
}
}
- PrivateAdbcSqliteBinderRelease(&binder_);
+ InternalAdbcSqliteBinderRelease(&binder_);
return Statement::ReleaseImpl();
}
diff --git a/c/driver/sqlite/sqlite_test.cc b/c/driver/sqlite/sqlite_test.cc
index e6fcf3d6fc..62f15c6900 100644
--- a/c/driver/sqlite/sqlite_test.cc
+++ b/c/driver/sqlite/sqlite_test.cc
@@ -439,7 +439,7 @@ class SqliteReaderTest : public ::testing::Test {
}
void TearDown() override {
if (error.release) error.release(&error);
- PrivateAdbcSqliteBinderRelease(&binder);
+ InternalAdbcSqliteBinderRelease(&binder);
sqlite3_finalize(stmt);
sqlite3_close(db);
}
@@ -463,7 +463,7 @@ class SqliteReaderTest : public ::testing::Test {
}
void Bind(struct ArrowArrayStream* stream) {
- ASSERT_THAT(PrivateAdbcSqliteBinderSetArrayStream(&binder, stream, &error),
+ ASSERT_THAT(InternalAdbcSqliteBinderSetArrayStream(&binder, stream, &error),
IsOkStatus(&error));
}
@@ -482,8 +482,8 @@ class SqliteReaderTest : public ::testing::Test {
/*pzTail=*/nullptr));
struct AdbcSqliteBinder* binder =
this->binder.schema.release ? &this->binder : nullptr;
- ASSERT_THAT(PrivateAdbcSqliteExportReader(db, stmt, binder, infer_rows,
- &reader->stream.value, &error),
+ ASSERT_THAT(InternalAdbcSqliteExportReader(db, stmt, binder, infer_rows,
+ &reader->stream.value, &error),
IsOkStatus(&error));
ASSERT_NO_FATAL_FAILURE(reader->GetSchema());
}
diff --git a/c/driver/sqlite/statement_reader.c b/c/driver/sqlite/statement_reader.c
index fe4adc27d5..1ba87abeaf 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -34,8 +34,8 @@
#include "driver/common/utils.h"
-AdbcStatusCode PrivateAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
- struct AdbcError* error) {
+AdbcStatusCode InternalAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
+ struct AdbcError* error) {
int status = binder->params.get_schema(&binder->params, &binder->schema);
if (status != 0) {
const char* message = binder->params.get_last_error(&binder->params);
@@ -108,13 +108,13 @@ AdbcStatusCode PrivateAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
return ADBC_STATUS_OK;
}
-AdbcStatusCode PrivateAdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
- struct ArrowArrayStream* values,
- struct AdbcError* error) {
- PrivateAdbcSqliteBinderRelease(binder);
+AdbcStatusCode InternalAdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
+ struct ArrowArrayStream* values,
+ struct AdbcError* error) {
+ InternalAdbcSqliteBinderRelease(binder);
binder->params = *values;
memset(values, 0, sizeof(*values));
- return PrivateAdbcSqliteBinderSet(binder, error);
+ return InternalAdbcSqliteBinderSet(binder, error);
}
#define SECONDS_PER_DAY 86400
@@ -270,9 +270,9 @@ static AdbcStatusCode ArrowTimestampToIsoString(int64_t value, enum ArrowTimeUni
return ADBC_STATUS_OK;
}
-AdbcStatusCode PrivateAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
- sqlite3* conn, sqlite3_stmt* stmt,
- char* finished, struct AdbcError* error) {
+AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
+ sqlite3* conn, sqlite3_stmt* stmt,
+ char* finished, struct AdbcError* error) {
struct ArrowError arrow_error = {0};
int status = 0;
while (!binder->array.release || binder->next_row >= binder->array.length) {
@@ -300,7 +300,7 @@ AdbcStatusCode PrivateAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
if (!binder->array.release) {
*finished = 1;
- PrivateAdbcSqliteBinderRelease(binder);
+ InternalAdbcSqliteBinderRelease(binder);
return ADBC_STATUS_OK;
}
@@ -452,7 +452,7 @@ AdbcStatusCode PrivateAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
return ADBC_STATUS_OK;
}
-void PrivateAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder) {
+void InternalAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder) {
if (binder->schema.release) {
binder->schema.release(&binder->schema);
}
@@ -660,8 +660,8 @@ int StatementReaderGetNext(struct ArrowArrayStream* self, struct ArrowArray* out
} else {
char finished = 0;
struct AdbcError error = {0};
- status = PrivateAdbcSqliteBinderBindNext(reader->binder, reader->db, reader->stmt,
- &finished, &error);
+ status = InternalAdbcSqliteBinderBindNext(reader->binder, reader->db,
+ reader->stmt, &finished, &error);
if (status != ADBC_STATUS_OK) {
reader->done = 1;
status = EIO;
@@ -736,7 +736,7 @@ void StatementReaderRelease(struct ArrowArrayStream* self) {
free(reader->types);
}
if (reader->binder) {
- PrivateAdbcSqliteBinderRelease(reader->binder);
+ InternalAdbcSqliteBinderRelease(reader->binder);
}
free(self->private_data);
@@ -1125,11 +1125,11 @@ AdbcStatusCode StatementReaderInferOneValue(
return ADBC_STATUS_OK;
} // NOLINT(whitespace/indent)
-AdbcStatusCode PrivateAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
- struct AdbcSqliteBinder* binder,
- size_t batch_size,
- struct ArrowArrayStream* stream,
- struct AdbcError* error) {
+AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
+ struct AdbcSqliteBinder* binder,
+ size_t batch_size,
+ struct ArrowArrayStream* stream,
+ struct AdbcError* error) {
struct StatementReader* reader = malloc(sizeof(struct StatementReader));
memset(reader, 0, sizeof(struct StatementReader));
reader->db = db;
@@ -1155,7 +1155,7 @@ AdbcStatusCode PrivateAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
if (binder) {
char finished = 0;
- status = PrivateAdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
+ status = InternalAdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
if (finished) {
reader->done = 1;
}
@@ -1171,7 +1171,7 @@ AdbcStatusCode PrivateAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
break;
} else {
char finished = 0;
- status = PrivateAdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
+ status = InternalAdbcSqliteBinderBindNext(binder, db, stmt, &finished, error);
if (status != ADBC_STATUS_OK) break;
if (finished) {
reader->done = 1;
diff --git a/c/driver/sqlite/statement_reader.h b/c/driver/sqlite/statement_reader.h
index e72bf2998f..7563cd5523 100644
--- a/c/driver/sqlite/statement_reader.h
+++ b/c/driver/sqlite/statement_reader.h
@@ -41,15 +41,15 @@ struct ADBC_EXPORT AdbcSqliteBinder {
};
ADBC_EXPORT
-AdbcStatusCode PrivateAdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
- struct ArrowArrayStream* values,
- struct AdbcError* error);
+AdbcStatusCode InternalAdbcSqliteBinderSetArrayStream(struct AdbcSqliteBinder* binder,
+ struct ArrowArrayStream* values,
+ struct AdbcError* error);
ADBC_EXPORT
-AdbcStatusCode PrivateAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
- sqlite3* conn, sqlite3_stmt* stmt,
- char* finished, struct AdbcError* error);
+AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
+ sqlite3* conn, sqlite3_stmt* stmt,
+ char* finished, struct AdbcError* error);
ADBC_EXPORT
-void PrivateAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder);
+void InternalAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder);
/// \brief Initialize an ArrowArrayStream from a sqlite3_stmt.
/// \param[in] db The SQLite connection.
@@ -59,11 +59,11 @@ void PrivateAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder);
/// \param[out] stream The stream to export to.
/// \param[out] error Error details, if needed.
ADBC_EXPORT
-AdbcStatusCode PrivateAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
- struct AdbcSqliteBinder* binder,
- size_t batch_size,
- struct ArrowArrayStream* stream,
- struct AdbcError* error);
+AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
+ struct AdbcSqliteBinder* binder,
+ size_t batch_size,
+ struct ArrowArrayStream* stream,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/symbols.map b/c/symbols.map
index 5fc2d1375a..37128424f4 100644
--- a/c/symbols.map
+++ b/c/symbols.map
@@ -19,8 +19,8 @@
global:
# Only expose symbols from the ADBC API
Adbc*;
- # Needed for tests (unfortunately)
- PrivateAdbc*;
+ # Needed for tests, but namespaced so they are clearly not for public use
+ InternalAdbc*;
# Expose driver-specific initialization routines
FlightSQLDriverInit;
diff --git a/c/validation/adbc_validation_connection.cc b/c/validation/adbc_validation_connection.cc
index 999bcef5b4..9c9bdeff21 100644
--- a/c/validation/adbc_validation_connection.cc
+++ b/c/validation/adbc_validation_connection.cc
@@ -981,13 +981,13 @@ void ConnectionTest::TestMetadataGetObjectsPrimaryKey() {
<< "could not initialize the AdbcGetObjectsData object";
// Test primary key
- struct AdbcGetObjectsTable* table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* table = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_pkey_test");
ASSERT_NE(table, nullptr) << "could not find adbc_pkey_test table";
ASSERT_EQ(table->n_table_columns, 1);
- struct AdbcGetObjectsColumn* column = PrivateAdbcGetObjectsDataGetColumnByName(
+ struct AdbcGetObjectsColumn* column = InternalAdbcGetObjectsDataGetColumnByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_pkey_test", "id");
ASSERT_NE(column, nullptr) << "could not find id column on adbc_pkey_test table";
@@ -1000,7 +1000,7 @@ void ConnectionTest::TestMetadataGetObjectsPrimaryKey() {
ConstraintTest(constraint, "PRIMARY KEY", {"id"});
// Test composite primary key
- struct AdbcGetObjectsTable* composite_table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* composite_table = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_composite_pkey_test");
ASSERT_NE(composite_table, nullptr) << "could not find adbc_composite_pkey_test table";
@@ -1013,7 +1013,7 @@ void ConnectionTest::TestMetadataGetObjectsPrimaryKey() {
const char* parent_2_column_names[2] = {"id_primary_col1", "id_primary_col2"};
struct AdbcGetObjectsColumn* parent_2_column;
for (int column_name_index = 0; column_name_index < 2; column_name_index++) {
- parent_2_column = PrivateAdbcGetObjectsDataGetColumnByName(
+ parent_2_column = InternalAdbcGetObjectsDataGetColumnByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_composite_pkey_test", parent_2_column_names[column_name_index]);
ASSERT_NE(parent_2_column, nullptr)
@@ -1104,7 +1104,7 @@ void ConnectionTest::TestMetadataGetObjectsForeignKey() {
<< "could not initialize the AdbcGetObjectsData object";
// Test child table
- struct AdbcGetObjectsTable* child_table = PrivateAdbcGetObjectsDataGetTableByName(
+ struct AdbcGetObjectsTable* child_table = InternalAdbcGetObjectsDataGetTableByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_fkey_child_test");
ASSERT_NE(child_table, nullptr) << "could not find adbc_fkey_child_test table";
@@ -1115,7 +1115,7 @@ void ConnectionTest::TestMetadataGetObjectsForeignKey() {
const char* child_column_names[3] = {"id_child_col1", "id_child_col2", "id_child_col3"};
struct AdbcGetObjectsColumn* child_column;
for (int column_index = 0; column_index < 2; column_index++) {
- child_column = PrivateAdbcGetObjectsDataGetColumnByName(
+ child_column = InternalAdbcGetObjectsDataGetColumnByName(
*get_objects_data, quirks()->catalog().c_str(), quirks()->db_schema().c_str(),
"adbc_fkey_child_test", child_column_names[column_index]);
ASSERT_NE(child_column, nullptr)
diff --git a/c/validation/adbc_validation_util.h b/c/validation/adbc_validation_util.h
index 00091dcc97..d3eab643d1 100644
--- a/c/validation/adbc_validation_util.h
+++ b/c/validation/adbc_validation_util.h
@@ -242,9 +242,9 @@ struct StreamReader {
struct GetObjectsReader {
explicit GetObjectsReader(struct ArrowArrayView* array_view) {
// TODO: this swallows any construction errors
- get_objects_data_ = PrivateAdbcGetObjectsDataInit(array_view);
+ get_objects_data_ = InternalAdbcGetObjectsDataInit(array_view);
}
- ~GetObjectsReader() { PrivateAdbcGetObjectsDataDelete(get_objects_data_); }
+ ~GetObjectsReader() { InternalAdbcGetObjectsDataDelete(get_objects_data_); }
struct AdbcGetObjectsData* operator*() { return get_objects_data_; }
struct AdbcGetObjectsData* operator->() { return get_objects_data_; }
From 394f1ab2d925f1ad250c1ac53ed862377a92e539 Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 10:05:17 +0900
Subject: [PATCH 03/16] Namespace SQLite internals
---
c/driver/sqlite/statement_reader.c | 133 +++++++++++++++--------------
1 file changed, 70 insertions(+), 63 deletions(-)
diff --git a/c/driver/sqlite/statement_reader.c b/c/driver/sqlite/statement_reader.c
index 1ba87abeaf..54c3655212 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -469,7 +469,7 @@ void InternalAdbcSqliteBinderRelease(struct AdbcSqliteBinder* binder) {
memset(binder, 0, sizeof(*binder));
}
-struct StatementReader {
+struct InternalSqliteStatementReader {
sqlite3* db;
sqlite3_stmt* stmt;
enum ArrowType* types;
@@ -481,16 +481,17 @@ struct StatementReader {
int batch_size;
};
-const char* StatementReaderGetLastError(struct ArrowArrayStream* self) {
+const char* InternalSqliteStatementReaderGetLastError(struct ArrowArrayStream* self) {
if (!self->release || !self->private_data) {
return NULL;
}
- struct StatementReader* reader = (struct StatementReader*)self->private_data;
+ struct InternalSqliteStatementReader* reader =
+ (struct InternalSqliteStatementReader*)self->private_data;
return reader->error.message;
}
-void StatementReaderSetError(struct StatementReader* reader) {
+void InternalSqliteStatementReaderSetError(struct InternalSqliteStatementReader* reader) {
const char* msg = sqlite3_errmsg(reader->db);
// Reset here so that we don't get an error again in StatementRelease
(void)sqlite3_reset(reader->stmt);
@@ -498,8 +499,8 @@ void StatementReaderSetError(struct StatementReader* reader) {
reader->error.message[sizeof(reader->error.message) - 1] = '\0';
}
-int StatementReaderGetOneValue(struct StatementReader* reader, int col,
- struct ArrowArray* out) {
+int InternalSqliteStatementReaderGetOneValue(struct InternalSqliteStatementReader* reader,
+ int col, struct ArrowArray* out) {
int sqlite_type = sqlite3_column_type(reader->stmt, col);
if (sqlite_type == SQLITE_NULL) {
@@ -621,12 +622,14 @@ int StatementReaderGetOneValue(struct StatementReader* reader, int col,
return ENOTSUP;
}
-int StatementReaderGetNext(struct ArrowArrayStream* self, struct ArrowArray* out) {
+int InternalSqliteStatementReaderGetNext(struct ArrowArrayStream* self,
+ struct ArrowArray* out) {
if (!self->release || !self->private_data) {
return EINVAL;
}
- struct StatementReader* reader = (struct StatementReader*)self->private_data;
+ struct InternalSqliteStatementReader* reader =
+ (struct InternalSqliteStatementReader*)self->private_data;
if (reader->initial_batch.release != NULL) {
// Canonically return zero-row results as a stream with zero batches
if (reader->initial_batch.length == 0) {
@@ -681,17 +684,17 @@ int StatementReaderGetNext(struct ArrowArrayStream* self, struct ArrowArray* out
} else if (rc == SQLITE_ERROR) {
reader->done = 1;
status = EIO;
- StatementReaderSetError(reader);
+ InternalSqliteStatementReaderSetError(reader);
break;
} else if (rc != SQLITE_ROW) {
reader->done = 1;
status = ADBC_STATUS_INTERNAL;
- StatementReaderSetError(reader);
+ InternalSqliteStatementReaderSetError(reader);
break;
}
for (int col = 0; col < reader->schema.n_children; col++) {
- status = StatementReaderGetOneValue(reader, col, out->children[col]);
+ status = InternalSqliteStatementReaderGetOneValue(reader, col, out->children[col]);
if (status != 0) break;
}
@@ -714,18 +717,21 @@ int StatementReaderGetNext(struct ArrowArrayStream* self, struct ArrowArray* out
return status;
}
-int StatementReaderGetSchema(struct ArrowArrayStream* self, struct ArrowSchema* out) {
+int InternalSqliteStatementReaderGetSchema(struct ArrowArrayStream* self,
+ struct ArrowSchema* out) {
if (!self->release || !self->private_data) {
return EINVAL;
}
- struct StatementReader* reader = (struct StatementReader*)self->private_data;
+ struct InternalSqliteStatementReader* reader =
+ (struct InternalSqliteStatementReader*)self->private_data;
return ArrowSchemaDeepCopy(&reader->schema, out);
}
-void StatementReaderRelease(struct ArrowArrayStream* self) {
+void InternalSqliteStatementReaderRelease(struct ArrowArrayStream* self) {
if (self->private_data) {
- struct StatementReader* reader = (struct StatementReader*)self->private_data;
+ struct InternalSqliteStatementReader* reader =
+ (struct InternalSqliteStatementReader*)self->private_data;
if (reader->schema.release) {
reader->schema.release(&reader->schema);
}
@@ -772,12 +778,10 @@ void StatementReaderRelease(struct ArrowArrayStream* self) {
/// Initialize buffers for the first (type-inferred) batch of data.
/// Use raw buffers since the types may change.
-AdbcStatusCode StatementReaderInitializeInfer(int num_columns, size_t infer_rows,
- struct ArrowBitmap* validity,
- struct ArrowBuffer* data,
- struct ArrowBuffer* binary,
- enum ArrowType* current_type,
- struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderInitializeInfer(
+ int num_columns, size_t infer_rows, struct ArrowBitmap* validity,
+ struct ArrowBuffer* data, struct ArrowBuffer* binary, enum ArrowType* current_type,
+ struct AdbcError* error) {
for (int i = 0; i < num_columns; i++) {
ArrowBitmapInit(&validity[i]);
CHECK_NA(INTERNAL, ArrowBitmapReserve(&validity[i], infer_rows), error);
@@ -790,10 +794,11 @@ AdbcStatusCode StatementReaderInitializeInfer(int num_columns, size_t infer_rows
} // NOLINT(whitespace/indent)
/// Finalize the first (type-inferred) batch of data.
-AdbcStatusCode StatementReaderInferFinalize(
- sqlite3_stmt* stmt, int num_columns, int64_t num_rows, struct StatementReader* reader,
- struct ArrowBitmap* validity, struct ArrowBuffer* data, struct ArrowBuffer* binary,
- enum ArrowType* current_type, struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderInferFinalize(
+ sqlite3_stmt* stmt, int num_columns, int64_t num_rows,
+ struct InternalSqliteStatementReader* reader, struct ArrowBitmap* validity,
+ struct ArrowBuffer* data, struct ArrowBuffer* binary, enum ArrowType* current_type,
+ struct AdbcError* error) {
ArrowSchemaInit(&reader->schema);
CHECK_NA(INTERNAL, ArrowSchemaSetTypeStruct(&reader->schema, num_columns), error);
for (int col = 0; col < num_columns; col++) {
@@ -835,8 +840,8 @@ AdbcStatusCode StatementReaderInferFinalize(
}
// Convert an int64 typed column to double.
-AdbcStatusCode StatementReaderUpcastInt64ToDouble(struct ArrowBuffer* data,
- struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderUpcastInt64ToDouble(struct ArrowBuffer* data,
+ struct AdbcError* error) {
struct ArrowBuffer doubles;
ArrowBufferInit(&doubles);
CHECK_NA(INTERNAL, ArrowBufferReserve(&doubles, data->capacity_bytes), error);
@@ -852,10 +857,9 @@ AdbcStatusCode StatementReaderUpcastInt64ToDouble(struct ArrowBuffer* data,
return ADBC_STATUS_OK;
}
-AdbcStatusCode StatementReaderAppendInt64ToBinary(struct ArrowBuffer* offsets,
- struct ArrowBuffer* binary,
- int64_t value, int32_t* offset,
- struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderAppendInt64ToBinary(
+ struct ArrowBuffer* offsets, struct ArrowBuffer* binary, int64_t value,
+ int32_t* offset, struct AdbcError* error) {
// Make sure we have at least 21 bytes available (19 digits + sign + null)
// Presumably this is enough, but manpage for snprintf makes no guarantees
// about whether locale may affect this, so check for truncation regardless
@@ -888,10 +892,9 @@ AdbcStatusCode StatementReaderAppendInt64ToBinary(struct ArrowBuffer* offsets,
return ADBC_STATUS_OK;
}
-AdbcStatusCode StatementReaderAppendDoubleToBinary(struct ArrowBuffer* offsets,
- struct ArrowBuffer* binary,
- double value, int32_t* offset,
- struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderAppendDoubleToBinary(
+ struct ArrowBuffer* offsets, struct ArrowBuffer* binary, double value,
+ int32_t* offset, struct AdbcError* error) {
static const size_t kReserve = 64;
size_t buffer_size = kReserve;
CHECK_NA(INTERNAL, ArrowBufferReserve(binary, buffer_size), error);
@@ -921,9 +924,8 @@ AdbcStatusCode StatementReaderAppendDoubleToBinary(struct ArrowBuffer* offsets,
return ADBC_STATUS_OK;
}
-AdbcStatusCode StatementReaderUpcastInt64ToBinary(struct ArrowBuffer* data,
- struct ArrowBuffer* binary,
- struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderUpcastInt64ToBinary(
+ struct ArrowBuffer* data, struct ArrowBuffer* binary, struct AdbcError* error) {
struct ArrowBuffer offsets;
ArrowBufferInit(&offsets);
ArrowBufferInit(binary);
@@ -936,8 +938,8 @@ AdbcStatusCode StatementReaderUpcastInt64ToBinary(struct ArrowBuffer* data,
int32_t offset = 0;
ArrowBufferAppendUnsafe(&offsets, &offset, sizeof(int32_t));
for (size_t i = 0; i < num_elements; i++) {
- AdbcStatusCode status =
- StatementReaderAppendInt64ToBinary(&offsets, binary, elements[i], &offset, error);
+ AdbcStatusCode status = InternalSqliteStatementReaderAppendInt64ToBinary(
+ &offsets, binary, elements[i], &offset, error);
if (status != ADBC_STATUS_OK) return status;
}
ArrowBufferReset(data);
@@ -945,9 +947,8 @@ AdbcStatusCode StatementReaderUpcastInt64ToBinary(struct ArrowBuffer* data,
return ADBC_STATUS_OK;
}
-AdbcStatusCode StatementReaderUpcastDoubleToBinary(struct ArrowBuffer* data,
- struct ArrowBuffer* binary,
- struct AdbcError* error) {
+AdbcStatusCode InternalSqliteStatementReaderUpcastDoubleToBinary(
+ struct ArrowBuffer* data, struct ArrowBuffer* binary, struct AdbcError* error) {
struct ArrowBuffer offsets;
ArrowBufferInit(&offsets);
ArrowBufferInit(binary);
@@ -960,7 +961,7 @@ AdbcStatusCode StatementReaderUpcastDoubleToBinary(struct ArrowBuffer* data,
int32_t offset = 0;
ArrowBufferAppendUnsafe(&offsets, &offset, sizeof(int32_t));
for (size_t i = 0; i < num_elements; i++) {
- AdbcStatusCode status = StatementReaderAppendDoubleToBinary(
+ AdbcStatusCode status = InternalSqliteStatementReaderAppendDoubleToBinary(
&offsets, binary, elements[i], &offset, error);
if (status != ADBC_STATUS_OK) return status;
}
@@ -970,7 +971,7 @@ AdbcStatusCode StatementReaderUpcastDoubleToBinary(struct ArrowBuffer* data,
}
/// Append a single value to a single column.
-AdbcStatusCode StatementReaderInferOneValue(
+AdbcStatusCode InternalSqliteStatementReaderInferOneValue(
sqlite3_stmt* stmt, int col, struct ArrowBitmap* validity, struct ArrowBuffer* data,
struct ArrowBuffer* binary, enum ArrowType* current_type, struct AdbcError* error) {
// TODO: static_assert sizeof(int64) == sizeof(double)
@@ -1018,7 +1019,7 @@ AdbcStatusCode StatementReaderInferOneValue(
case NANOARROW_TYPE_STRING:
case NANOARROW_TYPE_BINARY: {
int32_t offset = ((int32_t*)data->data)[data->size_bytes / 4 - 1];
- return StatementReaderAppendInt64ToBinary(
+ return InternalSqliteStatementReaderAppendInt64ToBinary(
data, binary, sqlite3_column_int64(stmt, col), &offset, error);
}
default:
@@ -1031,7 +1032,8 @@ AdbcStatusCode StatementReaderInferOneValue(
switch (*current_type) {
case NANOARROW_TYPE_INT64: {
- AdbcStatusCode status = StatementReaderUpcastInt64ToDouble(data, error);
+ AdbcStatusCode status =
+ InternalSqliteStatementReaderUpcastInt64ToDouble(data, error);
if (status != ADBC_STATUS_OK) return status;
*current_type = NANOARROW_TYPE_DOUBLE;
double value = sqlite3_column_double(stmt, col);
@@ -1046,7 +1048,7 @@ AdbcStatusCode StatementReaderInferOneValue(
case NANOARROW_TYPE_STRING:
case NANOARROW_TYPE_BINARY: {
int32_t offset = ((int32_t*)data->data)[data->size_bytes / 4 - 1];
- return StatementReaderAppendDoubleToBinary(
+ return InternalSqliteStatementReaderAppendDoubleToBinary(
data, binary, sqlite3_column_double(stmt, col), &offset, error);
}
default:
@@ -1059,14 +1061,15 @@ AdbcStatusCode StatementReaderInferOneValue(
switch (*current_type) {
case NANOARROW_TYPE_INT64: {
- AdbcStatusCode status = StatementReaderUpcastInt64ToBinary(data, binary, error);
+ AdbcStatusCode status =
+ InternalSqliteStatementReaderUpcastInt64ToBinary(data, binary, error);
if (status != ADBC_STATUS_OK) return status;
*current_type = NANOARROW_TYPE_STRING;
break;
}
case NANOARROW_TYPE_DOUBLE: {
AdbcStatusCode status =
- StatementReaderUpcastDoubleToBinary(data, binary, error);
+ InternalSqliteStatementReaderUpcastDoubleToBinary(data, binary, error);
if (status != ADBC_STATUS_OK) return status;
*current_type = NANOARROW_TYPE_STRING;
break;
@@ -1090,14 +1093,15 @@ AdbcStatusCode StatementReaderInferOneValue(
switch (*current_type) {
case NANOARROW_TYPE_INT64: {
- AdbcStatusCode status = StatementReaderUpcastInt64ToBinary(data, binary, error);
+ AdbcStatusCode status =
+ InternalSqliteStatementReaderUpcastInt64ToBinary(data, binary, error);
if (status != ADBC_STATUS_OK) return status;
*current_type = NANOARROW_TYPE_BINARY;
break;
}
case NANOARROW_TYPE_DOUBLE: {
AdbcStatusCode status =
- StatementReaderUpcastDoubleToBinary(data, binary, error);
+ InternalSqliteStatementReaderUpcastDoubleToBinary(data, binary, error);
if (status != ADBC_STATUS_OK) return status;
*current_type = NANOARROW_TYPE_BINARY;
break;
@@ -1130,17 +1134,18 @@ AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
size_t batch_size,
struct ArrowArrayStream* stream,
struct AdbcError* error) {
- struct StatementReader* reader = malloc(sizeof(struct StatementReader));
- memset(reader, 0, sizeof(struct StatementReader));
+ struct InternalSqliteStatementReader* reader =
+ malloc(sizeof(struct InternalSqliteStatementReader));
+ memset(reader, 0, sizeof(struct InternalSqliteStatementReader));
reader->db = db;
reader->stmt = stmt;
reader->batch_size = (int)batch_size;
stream->private_data = reader;
- stream->release = StatementReaderRelease;
- stream->get_last_error = StatementReaderGetLastError;
- stream->get_next = StatementReaderGetNext;
- stream->get_schema = StatementReaderGetSchema;
+ stream->release = InternalSqliteStatementReaderRelease;
+ stream->get_last_error = InternalSqliteStatementReaderGetLastError;
+ stream->get_next = InternalSqliteStatementReaderGetNext;
+ stream->get_schema = InternalSqliteStatementReaderGetSchema;
sqlite3_mutex_enter(sqlite3_db_mutex(db));
@@ -1150,7 +1155,7 @@ AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
struct ArrowBuffer* binary = malloc(num_columns * sizeof(struct ArrowBuffer));
enum ArrowType* current_type = malloc(num_columns * sizeof(enum ArrowType));
- AdbcStatusCode status = StatementReaderInitializeInfer(
+ AdbcStatusCode status = InternalSqliteStatementReaderInitializeInfer(
num_columns, batch_size, validity, data, binary, current_type, error);
if (binder) {
@@ -1191,8 +1196,9 @@ AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
}
for (int col = 0; col < num_columns; col++) {
- status = StatementReaderInferOneValue(stmt, col, &validity[col], &data[col],
- &binary[col], ¤t_type[col], error);
+ status = InternalSqliteStatementReaderInferOneValue(stmt, col, &validity[col],
+ &data[col], &binary[col],
+ ¤t_type[col], error);
if (status != ADBC_STATUS_OK) break;
}
if (status != ADBC_STATUS_OK) break;
@@ -1200,8 +1206,9 @@ AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
}
if (status == ADBC_STATUS_OK) {
- status = StatementReaderInferFinalize(stmt, num_columns, num_rows, reader, validity,
- data, binary, current_type, error);
+ status = InternalSqliteStatementReaderInferFinalize(stmt, num_columns, num_rows,
+ reader, validity, data, binary,
+ current_type, error);
}
}
From 48a93a5c4873f6be9b340c89f2f40c3bd2c83c59 Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 10:23:48 +0900
Subject: [PATCH 04/16] Namespace common internals
---
c/driver/common/utils.c | 26 +++--
c/driver/common/utils.h | 77 +++++++------
c/driver/common/utils_test.cc | 60 +++++-----
c/driver/flightsql/dremio_flightsql_test.cc | 2 +-
c/driver/postgresql/connection.cc | 63 +++++-----
c/driver/postgresql/database.cc | 22 ++--
c/driver/postgresql/postgresql.cc | 12 +-
c/driver/postgresql/statement.cc | 95 +++++++++-------
c/driver/sqlite/statement_reader.c | 120 +++++++++++---------
9 files changed, 261 insertions(+), 216 deletions(-)
diff --git a/c/driver/common/utils.c b/c/driver/common/utils.c
index dd9291eb9f..4dc8214ef5 100644
--- a/c/driver/common/utils.c
+++ b/c/driver/common/utils.c
@@ -104,14 +104,15 @@ static void ReleaseError(struct AdbcError* error) {
error->release = NULL;
}
-void SetError(struct AdbcError* error, const char* format, ...) {
+void InternalAdbcSetError(struct AdbcError* error, const char* format, ...) {
va_list args;
va_start(args, format);
- SetErrorVariadic(error, format, args);
+ InternalAdbcSetErrorVariadic(error, format, args);
va_end(args);
}
-void SetErrorVariadic(struct AdbcError* error, const char* format, va_list args) {
+void InternalAdbcSetErrorVariadic(struct AdbcError* error, const char* format,
+ va_list args) {
if (!error) return;
if (error->release) {
// TODO: combine the errors if possible
@@ -147,8 +148,8 @@ void SetErrorVariadic(struct AdbcError* error, const char* format, va_list args)
vsnprintf(error->message, kErrorBufferSize, format, args);
}
-void AppendErrorDetail(struct AdbcError* error, const char* key, const uint8_t* detail,
- size_t detail_length) {
+void InternalAdbcAppendErrorDetail(struct AdbcError* error, const char* key,
+ const uint8_t* detail, size_t detail_length) {
if (error->release != ReleaseErrorWithDetails) return;
struct AdbcErrorDetails* details = (struct AdbcErrorDetails*)error->private_data;
@@ -212,7 +213,7 @@ void AppendErrorDetail(struct AdbcError* error, const char* key, const uint8_t*
details->count++;
}
-int CommonErrorGetDetailCount(const struct AdbcError* error) {
+int InternalAdbcCommonErrorGetDetailCount(const struct AdbcError* error) {
if (error->release != ReleaseErrorWithDetails) {
return 0;
}
@@ -220,7 +221,8 @@ int CommonErrorGetDetailCount(const struct AdbcError* error) {
return details->count;
}
-struct AdbcErrorDetail CommonErrorGetDetail(const struct AdbcError* error, int index) {
+struct AdbcErrorDetail InternalAdbcCommonErrorGetDetail(const struct AdbcError* error,
+ int index) {
if (error->release != ReleaseErrorWithDetails) {
return (struct AdbcErrorDetail){NULL, NULL, 0};
}
@@ -235,11 +237,12 @@ struct AdbcErrorDetail CommonErrorGetDetail(const struct AdbcError* error, int i
};
}
-bool IsCommonError(const struct AdbcError* error) {
+bool InternalAdbcIsCommonError(const struct AdbcError* error) {
return error->release == ReleaseErrorWithDetails || error->release == ReleaseError;
}
-int StringBuilderInit(struct StringBuilder* builder, size_t initial_size) {
+int InternalAdbcStringBuilderInit(struct InternalAdbcStringBuilder* builder,
+ size_t initial_size) {
builder->buffer = (char*)malloc(initial_size);
if (builder->buffer == NULL) return errno;
@@ -248,7 +251,8 @@ int StringBuilderInit(struct StringBuilder* builder, size_t initial_size) {
return 0;
}
-int StringBuilderAppend(struct StringBuilder* builder, const char* fmt, ...) {
+int InternalAdbcStringBuilderAppend(struct InternalAdbcStringBuilder* builder,
+ const char* fmt, ...) {
va_list argptr;
int bytes_available = (int)builder->capacity - (int)builder->size;
@@ -278,7 +282,7 @@ int StringBuilderAppend(struct StringBuilder* builder, const char* fmt, ...) {
return 0;
}
-void StringBuilderReset(struct StringBuilder* builder) {
+void InternalAdbcStringBuilderReset(struct InternalAdbcStringBuilder* builder) {
if (builder->buffer) {
free(builder->buffer);
}
diff --git a/c/driver/common/utils.h b/c/driver/common/utils.h
index b4fd476863..fa727d0505 100644
--- a/c/driver/common/utils.h
+++ b/c/driver/common/utils.h
@@ -41,64 +41,69 @@ int InternalAdbcStatusCodeToErrno(AdbcStatusCode code);
#endif
/// Set error message using a format string.
-void SetError(struct AdbcError* error, const char* format,
- ...) ADBC_CHECK_PRINTF_ATTRIBUTE;
+void InternalAdbcSetError(struct AdbcError* error, const char* format,
+ ...) ADBC_CHECK_PRINTF_ATTRIBUTE;
/// Set error message using a format string.
-void SetErrorVariadic(struct AdbcError* error, const char* format, va_list args);
+void InternalAdbcSetErrorVariadic(struct AdbcError* error, const char* format,
+ va_list args);
/// Add an error detail.
-void AppendErrorDetail(struct AdbcError* error, const char* key, const uint8_t* detail,
- size_t detail_length);
+void InternalAdbcAppendErrorDetail(struct AdbcError* error, const char* key,
+ const uint8_t* detail, size_t detail_length);
-int CommonErrorGetDetailCount(const struct AdbcError* error);
-struct AdbcErrorDetail CommonErrorGetDetail(const struct AdbcError* error, int index);
-bool IsCommonError(const struct AdbcError* error);
+int InternalAdbcCommonErrorGetDetailCount(const struct AdbcError* error);
+struct AdbcErrorDetail InternalAdbcCommonErrorGetDetail(const struct AdbcError* error,
+ int index);
+bool InternalAdbcIsCommonError(const struct AdbcError* error);
-struct StringBuilder {
+struct InternalAdbcStringBuilder {
char* buffer;
// Not including null terminator
size_t size;
size_t capacity;
};
-int StringBuilderInit(struct StringBuilder* builder, size_t initial_size);
+int InternalAdbcStringBuilderInit(struct InternalAdbcStringBuilder* builder,
+ size_t initial_size);
-int ADBC_CHECK_PRINTF_ATTRIBUTE StringBuilderAppend(struct StringBuilder* builder,
- const char* fmt, ...);
-void StringBuilderReset(struct StringBuilder* builder);
+int ADBC_CHECK_PRINTF_ATTRIBUTE InternalAdbcStringBuilderAppend(
+ struct InternalAdbcStringBuilder* builder, const char* fmt, ...);
+void InternalAdbcStringBuilderReset(struct InternalAdbcStringBuilder* builder);
#undef ADBC_CHECK_PRINTF_ATTRIBUTE
/// Check an NanoArrow status code.
-#define CHECK_NA(CODE, EXPR, ERROR) \
- do { \
- ArrowErrorCode arrow_error_code = (EXPR); \
- if (arrow_error_code != 0) { \
- SetError(ERROR, "%s failed: (%d) %s\nDetail: %s:%d", #EXPR, arrow_error_code, \
- strerror(arrow_error_code), __FILE__, __LINE__); \
- return ADBC_STATUS_##CODE; \
- } \
+#define CHECK_NA(CODE, EXPR, ERROR) \
+ do { \
+ ArrowErrorCode arrow_error_code = (EXPR); \
+ if (arrow_error_code != 0) { \
+ InternalAdbcSetError(ERROR, "%s failed: (%d) %s\nDetail: %s:%d", #EXPR, \
+ arrow_error_code, strerror(arrow_error_code), __FILE__, \
+ __LINE__); \
+ return ADBC_STATUS_##CODE; \
+ } \
} while (0)
/// Check an NanoArrow status code.
-#define CHECK_NA_DETAIL(CODE, EXPR, NA_ERROR, ERROR) \
- do { \
- ArrowErrorCode arrow_error_code = (EXPR); \
- if (arrow_error_code != 0) { \
- SetError(ERROR, "%s failed: (%d) %s: %s\nDetail: %s:%d", #EXPR, arrow_error_code, \
- strerror(arrow_error_code), (NA_ERROR)->message, __FILE__, __LINE__); \
- return ADBC_STATUS_##CODE; \
- } \
+#define CHECK_NA_DETAIL(CODE, EXPR, NA_ERROR, ERROR) \
+ do { \
+ ArrowErrorCode arrow_error_code = (EXPR); \
+ if (arrow_error_code != 0) { \
+ InternalAdbcSetError(ERROR, "%s failed: (%d) %s: %s\nDetail: %s:%d", #EXPR, \
+ arrow_error_code, strerror(arrow_error_code), \
+ (NA_ERROR)->message, __FILE__, __LINE__); \
+ return ADBC_STATUS_##CODE; \
+ } \
} while (0)
/// Check a generic status.
-#define RAISE(CODE, EXPR, ERRMSG, ERROR) \
- do { \
- if (!(EXPR)) { \
- SetError(ERROR, "%s failed: %s\nDetail: %s:%d", #EXPR, ERRMSG, __FILE__, \
- __LINE__); \
- return ADBC_STATUS_##CODE; \
- } \
+#define RAISE(CODE, EXPR, ERRMSG, ERROR) \
+ do { \
+ if (!(EXPR)) { \
+ InternalAdbcSetError(ERROR, "%s failed: %s\nDetail: %s:%d", #EXPR, ERRMSG, \
+ __FILE__, __LINE__); \
+ return ADBC_STATUS_##CODE; \
+ } \
} while (0)
/// Check an NanoArrow status code.
diff --git a/c/driver/common/utils_test.cc b/c/driver/common/utils_test.cc
index 3e44765d1f..a772ef4ade 100644
--- a/c/driver/common/utils_test.cc
+++ b/c/driver/common/utils_test.cc
@@ -26,76 +26,76 @@
#include "utils.h"
TEST(TestStringBuilder, TestBasic) {
- struct StringBuilder str;
+ struct InternalAdbcStringBuilder str;
int ret;
- ret = StringBuilderInit(&str, /*initial_size=*/64);
+ ret = InternalAdbcStringBuilderInit(&str, /*initial_size=*/64);
EXPECT_EQ(ret, 0);
EXPECT_EQ(str.capacity, 64);
- ret = StringBuilderAppend(&str, "%s", "BASIC TEST");
+ ret = InternalAdbcStringBuilderAppend(&str, "%s", "BASIC TEST");
EXPECT_EQ(ret, 0);
EXPECT_EQ(str.size, 10);
EXPECT_STREQ(str.buffer, "BASIC TEST");
- StringBuilderReset(&str);
+ InternalAdbcStringBuilderReset(&str);
}
TEST(TestStringBuilder, TestBoundary) {
- struct StringBuilder str;
+ struct InternalAdbcStringBuilder str;
int ret;
- ret = StringBuilderInit(&str, /*initial_size=*/10);
+ ret = InternalAdbcStringBuilderInit(&str, /*initial_size=*/10);
EXPECT_EQ(ret, 0);
EXPECT_EQ(str.capacity, 10);
- ret = StringBuilderAppend(&str, "%s", "BASIC TEST");
+ ret = InternalAdbcStringBuilderAppend(&str, "%s", "BASIC TEST");
EXPECT_EQ(ret, 0);
// should resize to include \0
EXPECT_EQ(str.capacity, 11);
EXPECT_EQ(str.size, 10);
EXPECT_STREQ(str.buffer, "BASIC TEST");
- StringBuilderReset(&str);
+ InternalAdbcStringBuilderReset(&str);
}
TEST(TestStringBuilder, TestMultipleAppends) {
- struct StringBuilder str;
+ struct InternalAdbcStringBuilder str;
int ret;
- ret = StringBuilderInit(&str, /*initial_size=*/2);
+ ret = InternalAdbcStringBuilderInit(&str, /*initial_size=*/2);
EXPECT_EQ(ret, 0);
EXPECT_EQ(str.capacity, 2);
- ret = StringBuilderAppend(&str, "%s", "BASIC");
+ ret = InternalAdbcStringBuilderAppend(&str, "%s", "BASIC");
EXPECT_EQ(ret, 0);
EXPECT_EQ(str.capacity, 6);
EXPECT_EQ(str.size, 5);
EXPECT_STREQ(str.buffer, "BASIC");
- ret = StringBuilderAppend(&str, "%s", " TEST");
+ ret = InternalAdbcStringBuilderAppend(&str, "%s", " TEST");
EXPECT_EQ(ret, 0);
EXPECT_EQ(str.capacity, 11);
EXPECT_EQ(str.size, 10);
EXPECT_STREQ(str.buffer, "BASIC TEST");
- StringBuilderReset(&str);
+ InternalAdbcStringBuilderReset(&str);
}
TEST(ErrorDetails, Adbc100) {
struct AdbcError error;
std::memset(&error, 0, ADBC_ERROR_1_1_0_SIZE);
- SetError(&error, "My message");
+ InternalAdbcSetError(&error, "My message");
ASSERT_EQ(nullptr, error.private_data);
ASSERT_EQ(nullptr, error.private_driver);
{
std::string detail = "detail";
- AppendErrorDetail(&error, "key", reinterpret_cast(detail.data()),
- detail.size());
+ InternalAdbcAppendErrorDetail(
+ &error, "key", reinterpret_cast(detail.data()), detail.size());
}
- ASSERT_EQ(0, CommonErrorGetDetailCount(&error));
- struct AdbcErrorDetail detail = CommonErrorGetDetail(&error, 0);
+ ASSERT_EQ(0, InternalAdbcCommonErrorGetDetailCount(&error));
+ struct AdbcErrorDetail detail = InternalAdbcCommonErrorGetDetail(&error, 0);
ASSERT_EQ(nullptr, detail.key);
ASSERT_EQ(nullptr, detail.value);
ASSERT_EQ(0, detail.value_length);
@@ -105,29 +105,29 @@ TEST(ErrorDetails, Adbc100) {
TEST(ErrorDetails, Adbc110) {
struct AdbcError error = ADBC_ERROR_INIT;
- SetError(&error, "My message");
+ InternalAdbcSetError(&error, "My message");
ASSERT_NE(nullptr, error.private_data);
ASSERT_EQ(nullptr, error.private_driver);
{
std::string detail = "detail";
- AppendErrorDetail(&error, "key", reinterpret_cast(detail.data()),
- detail.size());
+ InternalAdbcAppendErrorDetail(
+ &error, "key", reinterpret_cast(detail.data()), detail.size());
}
- ASSERT_EQ(1, CommonErrorGetDetailCount(&error));
- struct AdbcErrorDetail detail = CommonErrorGetDetail(&error, 0);
+ ASSERT_EQ(1, InternalAdbcCommonErrorGetDetailCount(&error));
+ struct AdbcErrorDetail detail = InternalAdbcCommonErrorGetDetail(&error, 0);
ASSERT_STREQ("key", detail.key);
ASSERT_EQ("detail", std::string_view(reinterpret_cast(detail.value),
detail.value_length));
- detail = CommonErrorGetDetail(&error, -1);
+ detail = InternalAdbcCommonErrorGetDetail(&error, -1);
ASSERT_EQ(nullptr, detail.key);
ASSERT_EQ(nullptr, detail.value);
ASSERT_EQ(0, detail.value_length);
- detail = CommonErrorGetDetail(&error, 2);
+ detail = InternalAdbcCommonErrorGetDetail(&error, 2);
ASSERT_EQ(nullptr, detail.key);
ASSERT_EQ(nullptr, detail.value);
ASSERT_EQ(0, detail.value_length);
@@ -139,7 +139,7 @@ TEST(ErrorDetails, Adbc110) {
TEST(ErrorDetails, RoundTripValues) {
struct AdbcError error = ADBC_ERROR_INIT;
- SetError(&error, "My message");
+ InternalAdbcSetError(&error, "My message");
struct Detail {
std::string key;
@@ -152,13 +152,13 @@ TEST(ErrorDetails, RoundTripValues) {
};
for (const auto& detail : details) {
- AppendErrorDetail(&error, detail.key.c_str(), detail.value.data(),
- detail.value.size());
+ InternalAdbcAppendErrorDetail(&error, detail.key.c_str(), detail.value.data(),
+ detail.value.size());
}
- ASSERT_EQ(details.size(), CommonErrorGetDetailCount(&error));
+ ASSERT_EQ(details.size(), InternalAdbcCommonErrorGetDetailCount(&error));
for (int i = 0; i < static_cast(details.size()); i++) {
- struct AdbcErrorDetail detail = CommonErrorGetDetail(&error, i);
+ struct AdbcErrorDetail detail = InternalAdbcCommonErrorGetDetail(&error, i);
ASSERT_EQ(details[i].key, detail.key);
ASSERT_EQ(details[i].value.size(), detail.value_length);
ASSERT_THAT(std::vector(detail.value, detail.value + detail.value_length),
diff --git a/c/driver/flightsql/dremio_flightsql_test.cc b/c/driver/flightsql/dremio_flightsql_test.cc
index 341845d0e2..38944837d1 100644
--- a/c/driver/flightsql/dremio_flightsql_test.cc
+++ b/c/driver/flightsql/dremio_flightsql_test.cc
@@ -37,7 +37,7 @@ class DremioFlightSqlQuirks : public adbc_validation::DriverQuirks {
const char* user_raw = std::getenv("ADBC_DREMIO_FLIGHTSQL_USER");
const char* pass_raw = std::getenv("ADBC_DREMIO_FLIGHTSQL_PASS");
if (!uri_raw || !user_raw || !pass_raw) {
- SetError(error, "Missing required environment variables");
+ InternalAdbcSetError(error, "Missing required environment variables");
return ADBC_STATUS_INVALID_ARGUMENT;
}
EXPECT_THAT(AdbcDatabaseSetOption(database, "uri", uri_raw, error),
diff --git a/c/driver/postgresql/connection.cc b/c/driver/postgresql/connection.cc
index d3b6911387..8fa367e18b 100644
--- a/c/driver/postgresql/connection.cc
+++ b/c/driver/postgresql/connection.cc
@@ -463,7 +463,7 @@ AdbcStatusCode PostgresConnection::Cancel(struct AdbcError* error) {
// > The return value is 1 if the cancel request was successfully dispatched
// > and 0 if not.
if (PQcancel(cancel_, errbuf, sizeof(errbuf)) != 1) {
- SetError(error, "[libpq] Failed to cancel operation: %s", errbuf);
+ InternalAdbcSetError(error, "[libpq] Failed to cancel operation: %s", errbuf);
return ADBC_STATUS_UNKNOWN;
}
return ADBC_STATUS_OK;
@@ -471,7 +471,7 @@ AdbcStatusCode PostgresConnection::Cancel(struct AdbcError* error) {
AdbcStatusCode PostgresConnection::Commit(struct AdbcError* error) {
if (autocommit_) {
- SetError(error, "%s", "[libpq] Cannot commit when autocommit is enabled");
+ InternalAdbcSetError(error, "%s", "[libpq] Cannot commit when autocommit is enabled");
return ADBC_STATUS_INVALID_STATE;
}
@@ -526,7 +526,8 @@ AdbcStatusCode PostgresConnection::GetInfo(struct AdbcConnection* connection,
RAISE_STATUS(error, result_helper.Execute());
auto it = result_helper.begin();
if (it == result_helper.end()) {
- SetError(error, "[libpq] PostgreSQL returned no rows for '%s'", stmt);
+ InternalAdbcSetError(error, "[libpq] PostgreSQL returned no rows for '%s'",
+ stmt);
return ADBC_STATUS_INTERNAL;
}
const char* server_version_num = (*it)[0].data;
@@ -620,8 +621,8 @@ AdbcStatusCode PostgresConnection::GetOption(const char* option, char* value,
RAISE_STATUS(error, result_helper.Execute());
auto it = result_helper.begin();
if (it == result_helper.end()) {
- SetError(error,
- "[libpq] PostgreSQL returned no rows for 'SELECT CURRENT_SCHEMA()'");
+ InternalAdbcSetError(
+ error, "[libpq] PostgreSQL returned no rows for 'SELECT CURRENT_SCHEMA()'");
return ADBC_STATUS_INTERNAL;
}
output = (*it)[0].data;
@@ -813,7 +814,8 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
for (PqResultRow row : result_helper) {
auto reltuples = row[5].ParseDouble();
if (!reltuples) {
- SetError(error, "[libpq] Invalid double value in reltuples: '%s'", row[5].data);
+ InternalAdbcSetError(error, "[libpq] Invalid double value in reltuples: '%s'",
+ row[5].data);
return ADBC_STATUS_INTERNAL;
}
@@ -837,7 +839,8 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
auto null_frac = row[2].ParseDouble();
if (!null_frac) {
- SetError(error, "[libpq] Invalid double value in null_frac: '%s'", row[2].data);
+ InternalAdbcSetError(error, "[libpq] Invalid double value in null_frac: '%s'",
+ row[2].data);
return ADBC_STATUS_INTERNAL;
}
@@ -862,7 +865,8 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
auto average_byte_width = row[3].ParseDouble();
if (!average_byte_width) {
- SetError(error, "[libpq] Invalid double value in avg_width: '%s'", row[3].data);
+ InternalAdbcSetError(error, "[libpq] Invalid double value in avg_width: '%s'",
+ row[3].data);
return ADBC_STATUS_INTERNAL;
}
@@ -888,7 +892,8 @@ AdbcStatusCode PostgresConnectionGetStatisticsImpl(PGconn* conn, const char* db_
auto n_distinct = row[4].ParseDouble();
if (!n_distinct) {
- SetError(error, "[libpq] Invalid double value in avg_width: '%s'", row[4].data);
+ InternalAdbcSetError(error, "[libpq] Invalid double value in avg_width: '%s'",
+ row[4].data);
return ADBC_STATUS_INTERNAL;
}
@@ -938,13 +943,14 @@ AdbcStatusCode PostgresConnection::GetStatistics(const char* catalog,
struct AdbcError* error) {
// Simplify our jobs here
if (!approximate) {
- SetError(error, "[libpq] Exact statistics are not implemented");
+ InternalAdbcSetError(error, "[libpq] Exact statistics are not implemented");
return ADBC_STATUS_NOT_IMPLEMENTED;
} else if (!db_schema) {
- SetError(error, "[libpq] Must request statistics for a single schema");
+ InternalAdbcSetError(error, "[libpq] Must request statistics for a single schema");
return ADBC_STATUS_NOT_IMPLEMENTED;
} else if (catalog && std::strcmp(catalog, PQdb(conn_)) != 0) {
- SetError(error, "[libpq] Can only request statistics for current catalog");
+ InternalAdbcSetError(error,
+ "[libpq] Can only request statistics for current catalog");
return ADBC_STATUS_NOT_IMPLEMENTED;
}
@@ -1060,8 +1066,9 @@ AdbcStatusCode PostgresConnection::GetTableSchema(const char* catalog,
PostgresType pg_type;
if (type_resolver_->FindWithDefault(pg_oid, &pg_type) != NANOARROW_OK) {
- SetError(error, "%s%d%s%s%s%" PRIu32, "Error resolving type code for column #",
- row_counter + 1, " (\"", colname, "\") with oid ", pg_oid);
+ InternalAdbcSetError(error, "%s%d%s%s%s%" PRIu32,
+ "Error resolving type code for column #", row_counter + 1,
+ " (\"", colname, "\") with oid ", pg_oid);
final_status = ADBC_STATUS_NOT_IMPLEMENTED;
break;
}
@@ -1092,7 +1099,7 @@ AdbcStatusCode PostgresConnection::GetTableTypes(struct AdbcConnection* connecti
AdbcStatusCode PostgresConnection::Init(struct AdbcDatabase* database,
struct AdbcError* error) {
if (!database || !database->private_data) {
- SetError(error, "[libpq] Must provide an initialized AdbcDatabase");
+ InternalAdbcSetError(error, "[libpq] Must provide an initialized AdbcDatabase");
return ADBC_STATUS_INVALID_ARGUMENT;
}
database_ =
@@ -1103,7 +1110,7 @@ AdbcStatusCode PostgresConnection::Init(struct AdbcDatabase* database,
cancel_ = PQgetCancel(conn_);
if (!cancel_) {
- SetError(error, "[libpq] Could not initialize PGcancel");
+ InternalAdbcSetError(error, "[libpq] Could not initialize PGcancel");
return ADBC_STATUS_UNKNOWN;
}
@@ -1130,7 +1137,8 @@ AdbcStatusCode PostgresConnection::Release(struct AdbcError* error) {
AdbcStatusCode PostgresConnection::Rollback(struct AdbcError* error) {
if (autocommit_) {
- SetError(error, "%s", "[libpq] Cannot rollback when autocommit is enabled");
+ InternalAdbcSetError(error, "%s",
+ "[libpq] Cannot rollback when autocommit is enabled");
return ADBC_STATUS_INVALID_STATE;
}
@@ -1144,7 +1152,8 @@ AdbcStatusCode PostgresConnection::Rollback(struct AdbcError* error) {
PGresult* result = PQexec(conn_, "ROLLBACK AND CHAIN");
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
- SetError(error, "%s%s", "[libpq] Failed to rollback: ", PQerrorMessage(conn_));
+ InternalAdbcSetError(error, "%s%s",
+ "[libpq] Failed to rollback: ", PQerrorMessage(conn_));
PQclear(result);
return ADBC_STATUS_IO;
}
@@ -1161,7 +1170,8 @@ AdbcStatusCode PostgresConnection::SetOption(const char* key, const char* value,
} else if (std::strcmp(value, ADBC_OPTION_VALUE_DISABLED) == 0) {
autocommit = false;
} else {
- SetError(error, "%s%s%s%s", "[libpq] Invalid value for option ", key, ": ", value);
+ InternalAdbcSetError(error, "%s%s%s%s", "[libpq] Invalid value for option ", key,
+ ": ", value);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -1175,8 +1185,8 @@ AdbcStatusCode PostgresConnection::SetOption(const char* key, const char* value,
PGresult* result = PQexec(conn_, query);
if (PQresultStatus(result) != PGRES_COMMAND_OK) {
- SetError(error, "%s%s",
- "[libpq] Failed to update autocommit: ", PQerrorMessage(conn_));
+ InternalAdbcSetError(error, "%s%s", "[libpq] Failed to update autocommit: ",
+ PQerrorMessage(conn_));
PQclear(result);
return ADBC_STATUS_IO;
}
@@ -1193,7 +1203,8 @@ AdbcStatusCode PostgresConnection::SetOption(const char* key, const char* value,
// PostgreSQL doesn't accept a parameter here
char* value_esc = PQescapeIdentifier(conn_, value, strlen(value));
if (!value_esc) {
- SetError(error, "[libpq] Could not escape identifier: %s", PQerrorMessage(conn_));
+ InternalAdbcSetError(error, "[libpq] Could not escape identifier: %s",
+ PQerrorMessage(conn_));
return ADBC_STATUS_INTERNAL;
}
std::string query = fmt::format("SET search_path TO {}", value_esc);
@@ -1203,26 +1214,26 @@ AdbcStatusCode PostgresConnection::SetOption(const char* key, const char* value,
RAISE_STATUS(error, result_helper.Execute());
return ADBC_STATUS_OK;
}
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresConnection::SetOptionBytes(const char* key, const uint8_t* value,
size_t length,
struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresConnection::SetOptionDouble(const char* key, double value,
struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresConnection::SetOptionInt(const char* key, int64_t value,
struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
diff --git a/c/driver/postgresql/database.cc b/c/driver/postgresql/database.cc
index f5652e8fac..cecf7a6eb0 100644
--- a/c/driver/postgresql/database.cc
+++ b/c/driver/postgresql/database.cc
@@ -75,8 +75,8 @@ AdbcStatusCode PostgresDatabase::Init(struct AdbcError* error) {
AdbcStatusCode PostgresDatabase::Release(struct AdbcError* error) {
if (open_connections_ != 0) {
- SetError(error, "%s%" PRId32 "%s", "[libpq] Database released with ",
- open_connections_, " open connections");
+ InternalAdbcSetError(error, "%s%" PRId32 "%s", "[libpq] Database released with ",
+ open_connections_, " open connections");
return ADBC_STATUS_INVALID_STATE;
}
return ADBC_STATUS_OK;
@@ -87,7 +87,7 @@ AdbcStatusCode PostgresDatabase::SetOption(const char* key, const char* value,
if (strcmp(key, "uri") == 0) {
uri_ = value;
} else {
- SetError(error, "%s%s", "[libpq] Unknown database option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown database option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
return ADBC_STATUS_OK;
@@ -95,31 +95,33 @@ AdbcStatusCode PostgresDatabase::SetOption(const char* key, const char* value,
AdbcStatusCode PostgresDatabase::SetOptionBytes(const char* key, const uint8_t* value,
size_t length, struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresDatabase::SetOptionDouble(const char* key, double value,
struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresDatabase::SetOptionInt(const char* key, int64_t value,
struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresDatabase::Connect(PGconn** conn, struct AdbcError* error) {
if (uri_.empty()) {
- SetError(error, "%s",
- "[libpq] Must set database option 'uri' before creating a connection");
+ InternalAdbcSetError(
+ error, "%s",
+ "[libpq] Must set database option 'uri' before creating a connection");
return ADBC_STATUS_INVALID_STATE;
}
*conn = PQconnectdb(uri_.c_str());
if (PQstatus(*conn) != CONNECTION_OK) {
- SetError(error, "%s%s", "[libpq] Failed to connect: ", PQerrorMessage(*conn));
+ InternalAdbcSetError(error, "%s%s",
+ "[libpq] Failed to connect: ", PQerrorMessage(*conn));
PQfinish(*conn);
*conn = nullptr;
return ADBC_STATUS_IO;
@@ -132,7 +134,7 @@ AdbcStatusCode PostgresDatabase::Disconnect(PGconn** conn, struct AdbcError* err
PQfinish(*conn);
*conn = nullptr;
if (--open_connections_ < 0) {
- SetError(error, "%s", "[libpq] Open connection count underflowed");
+ InternalAdbcSetError(error, "%s", "[libpq] Open connection count underflowed");
return ADBC_STATUS_INTERNAL;
}
return ADBC_STATUS_OK;
diff --git a/c/driver/postgresql/postgresql.cc b/c/driver/postgresql/postgresql.cc
index ea4d354279..95e8ce7804 100644
--- a/c/driver/postgresql/postgresql.cc
+++ b/c/driver/postgresql/postgresql.cc
@@ -60,8 +60,8 @@ const struct AdbcError* PostgresErrorFromArrayStream(struct ArrowArrayStream* st
}
int PostgresErrorGetDetailCount(const struct AdbcError* error) {
- if (IsCommonError(error)) {
- return CommonErrorGetDetailCount(error);
+ if (InternalAdbcIsCommonError(error)) {
+ return InternalAdbcCommonErrorGetDetailCount(error);
}
if (error->vendor_code != ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA) {
@@ -73,8 +73,8 @@ int PostgresErrorGetDetailCount(const struct AdbcError* error) {
}
struct AdbcErrorDetail PostgresErrorGetDetail(const struct AdbcError* error, int index) {
- if (IsCommonError(error)) {
- return CommonErrorGetDetail(error, index);
+ if (InternalAdbcIsCommonError(error)) {
+ return InternalAdbcCommonErrorGetDetail(error, index);
}
auto error_obj = reinterpret_cast(error->private_data);
@@ -111,11 +111,11 @@ AdbcStatusCode PostgresDatabaseInit(struct AdbcDatabase* database,
AdbcStatusCode PostgresDatabaseNew(struct AdbcDatabase* database,
struct AdbcError* error) {
if (!database) {
- SetError(error, "%s", "[libpq] database must not be null");
+ InternalAdbcSetError(error, "%s", "[libpq] database must not be null");
return ADBC_STATUS_INVALID_STATE;
}
if (database->private_data) {
- SetError(error, "%s", "[libpq] database is already initialized");
+ InternalAdbcSetError(error, "%s", "[libpq] database is already initialized");
return ADBC_STATUS_INVALID_STATE;
}
auto impl = std::make_shared();
diff --git a/c/driver/postgresql/statement.cc b/c/driver/postgresql/statement.cc
index 5879e9de71..677236ef09 100644
--- a/c/driver/postgresql/statement.cc
+++ b/c/driver/postgresql/statement.cc
@@ -57,12 +57,12 @@ int TupleReader::GetSchema(struct ArrowSchema* out) {
int na_res = copy_reader_->GetSchema(out);
if (out->release == nullptr) {
- SetError(&error_, "[libpq] Result set was already consumed or freed");
+ InternalAdbcSetError(&error_, "[libpq] Result set was already consumed or freed");
status_ = ADBC_STATUS_INVALID_STATE;
return InternalAdbcStatusCodeToErrno(status_);
} else if (na_res != NANOARROW_OK) {
// e.g., Can't allocate memory
- SetError(&error_, "[libpq] Error copying schema");
+ InternalAdbcSetError(&error_, "[libpq] Error copying schema");
status_ = ADBC_STATUS_INTERNAL;
}
@@ -80,7 +80,8 @@ int TupleReader::GetCopyData() {
int get_copy_res = PQgetCopyData(conn_, &pgbuf_, /*async=*/0);
if (get_copy_res == -2) {
- SetError(&error_, "[libpq] PQgetCopyData() failed: %s", PQerrorMessage(conn_));
+ InternalAdbcSetError(&error_, "[libpq] PQgetCopyData() failed: %s",
+ PQerrorMessage(conn_));
status_ = ADBC_STATUS_IO;
return InternalAdbcStatusCodeToErrno(status_);
}
@@ -109,8 +110,8 @@ int TupleReader::AppendRowAndFetchNext() {
// call to PQgetCopyData())
int na_res = copy_reader_->ReadRecord(&data_, &na_error_);
if (na_res != NANOARROW_OK && na_res != ENODATA) {
- SetError(&error_, "[libpq] ReadRecord failed at row %" PRId64 ": %s", row_id_,
- na_error_.message);
+ InternalAdbcSetError(&error_, "[libpq] ReadRecord failed at row %" PRId64 ": %s",
+ row_id_, na_error_.message);
status_ = ADBC_STATUS_IO;
return na_res;
}
@@ -136,7 +137,8 @@ int TupleReader::BuildOutput(struct ArrowArray* out) {
int na_res = copy_reader_->GetArray(out, &na_error_);
if (na_res != NANOARROW_OK) {
- SetError(&error_, "[libpq] Failed to build result array: %s", na_error_.message);
+ InternalAdbcSetError(&error_, "[libpq] Failed to build result array: %s",
+ na_error_.message);
status_ = ADBC_STATUS_INTERNAL;
return na_res;
}
@@ -165,7 +167,7 @@ int TupleReader::GetNext(struct ArrowArray* out) {
na_res = copy_reader_->ReadHeader(&data_, &na_error_);
if (na_res != NANOARROW_OK) {
- SetError(&error_, "[libpq] ReadHeader() failed: %s", na_error_.message);
+ InternalAdbcSetError(&error_, "[libpq] ReadHeader() failed: %s", na_error_.message);
return na_res;
}
@@ -310,7 +312,8 @@ void TupleReader::ReleaseTrampoline(struct ArrowArrayStream* self) {
AdbcStatusCode PostgresStatement::New(struct AdbcConnection* connection,
struct AdbcError* error) {
if (!connection || !connection->private_data) {
- SetError(error, "%s", "[libpq] Must provide an initialized AdbcConnection");
+ InternalAdbcSetError(error, "%s",
+ "[libpq] Must provide an initialized AdbcConnection");
return ADBC_STATUS_INVALID_ARGUMENT;
}
connection_ =
@@ -324,10 +327,10 @@ AdbcStatusCode PostgresStatement::Bind(struct ArrowArray* values,
struct ArrowSchema* schema,
struct AdbcError* error) {
if (!values || !values->release) {
- SetError(error, "%s", "[libpq] Must provide non-NULL array");
+ InternalAdbcSetError(error, "%s", "[libpq] Must provide non-NULL array");
return ADBC_STATUS_INVALID_ARGUMENT;
} else if (!schema || !schema->release) {
- SetError(error, "%s", "[libpq] Must provide non-NULL schema");
+ InternalAdbcSetError(error, "%s", "[libpq] Must provide non-NULL schema");
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -340,7 +343,7 @@ AdbcStatusCode PostgresStatement::Bind(struct ArrowArray* values,
AdbcStatusCode PostgresStatement::Bind(struct ArrowArrayStream* stream,
struct AdbcError* error) {
if (!stream || !stream->release) {
- SetError(error, "%s", "[libpq] Must provide non-NULL stream");
+ InternalAdbcSetError(error, "%s", "[libpq] Must provide non-NULL stream");
return ADBC_STATUS_INVALID_ARGUMENT;
}
// Move stream
@@ -363,8 +366,9 @@ AdbcStatusCode PostgresStatement::CreateBulkTable(const std::string& current_sch
PGconn* conn = connection_->conn();
if (!ingest_.db_schema.empty() && ingest_.temporary) {
- SetError(error, "[libpq] Cannot set both %s and %s",
- ADBC_INGEST_OPTION_TARGET_DB_SCHEMA, ADBC_INGEST_OPTION_TEMPORARY);
+ InternalAdbcSetError(error, "[libpq] Cannot set both %s and %s",
+ ADBC_INGEST_OPTION_TARGET_DB_SCHEMA,
+ ADBC_INGEST_OPTION_TEMPORARY);
return ADBC_STATUS_INVALID_STATE;
}
@@ -373,8 +377,9 @@ AdbcStatusCode PostgresStatement::CreateBulkTable(const std::string& current_sch
char* escaped =
PQescapeIdentifier(conn, ingest_.db_schema.c_str(), ingest_.db_schema.size());
if (escaped == nullptr) {
- SetError(error, "[libpq] Failed to escape target schema %s for ingestion: %s",
- ingest_.db_schema.c_str(), PQerrorMessage(conn));
+ InternalAdbcSetError(
+ error, "[libpq] Failed to escape target schema %s for ingestion: %s",
+ ingest_.db_schema.c_str(), PQerrorMessage(conn));
return ADBC_STATUS_INTERNAL;
}
*escaped_table += escaped;
@@ -397,8 +402,9 @@ AdbcStatusCode PostgresStatement::CreateBulkTable(const std::string& current_sch
char* escaped =
PQescapeIdentifier(conn, ingest_.target.c_str(), ingest_.target.size());
if (escaped == nullptr) {
- SetError(error, "[libpq] Failed to escape target table %s for ingestion: %s",
- ingest_.target.c_str(), PQerrorMessage(conn));
+ InternalAdbcSetError(error,
+ "[libpq] Failed to escape target table %s for ingestion: %s",
+ ingest_.target.c_str(), PQerrorMessage(conn));
return ADBC_STATUS_INTERNAL;
}
*escaped_table += escaped;
@@ -451,8 +457,8 @@ AdbcStatusCode PostgresStatement::CreateBulkTable(const std::string& current_sch
const char* unescaped = source_schema.children[i]->name;
char* escaped = PQescapeIdentifier(conn, unescaped, std::strlen(unescaped));
if (escaped == nullptr) {
- SetError(error, "[libpq] Failed to escape column %s for ingestion: %s", unescaped,
- PQerrorMessage(conn));
+ InternalAdbcSetError(error, "[libpq] Failed to escape column %s for ingestion: %s",
+ unescaped, PQerrorMessage(conn));
return ADBC_STATUS_INTERNAL;
}
create += escaped;
@@ -473,7 +479,7 @@ AdbcStatusCode PostgresStatement::CreateBulkTable(const std::string& current_sch
}
create += ")";
- SetError(error, "%s%s", "[libpq] ", create.c_str());
+ InternalAdbcSetError(error, "%s%s", "[libpq] ", create.c_str());
PGresult* result = PQexecParams(conn, create.c_str(), /*nParams=*/0,
/*paramTypes=*/nullptr, /*paramValues=*/nullptr,
/*paramLengths=*/nullptr, /*paramFormats=*/nullptr,
@@ -511,7 +517,7 @@ AdbcStatusCode PostgresStatement::ExecuteQuery(struct ArrowArrayStream* stream,
}
if (query_.empty()) {
- SetError(error, "%s", "[libpq] Must SetSqlQuery before ExecuteQuery");
+ InternalAdbcSetError(error, "%s", "[libpq] Must SetSqlQuery before ExecuteQuery");
return ADBC_STATUS_INVALID_STATE;
}
@@ -575,7 +581,7 @@ AdbcStatusCode PostgresStatement::ExecuteSchema(struct ArrowSchema* schema,
struct AdbcError* error) {
ClearResult();
if (query_.empty()) {
- SetError(error, "%s", "[libpq] Must SetSqlQuery before ExecuteQuery");
+ InternalAdbcSetError(error, "%s", "[libpq] Must SetSqlQuery before ExecuteQuery");
return ADBC_STATUS_INVALID_STATE;
}
@@ -590,7 +596,7 @@ AdbcStatusCode PostgresStatement::ExecuteSchema(struct ArrowSchema* schema,
&na_error, error);
if (std::string(param_schema->format) != "+s") {
- SetError(error, "%s", "[libpq] Bind parameters must have type STRUCT");
+ InternalAdbcSetError(error, "%s", "[libpq] Bind parameters must have type STRUCT");
return ADBC_STATUS_INVALID_STATE;
}
@@ -628,12 +634,14 @@ AdbcStatusCode PostgresStatement::ExecuteIngest(struct ArrowArrayStream* stream,
int64_t* rows_affected,
struct AdbcError* error) {
if (!bind_.release) {
- SetError(error, "%s", "[libpq] Must Bind() before Execute() for bulk ingestion");
+ InternalAdbcSetError(error, "%s",
+ "[libpq] Must Bind() before Execute() for bulk ingestion");
return ADBC_STATUS_INVALID_STATE;
}
if (stream != nullptr) {
- SetError(error, "%s", "[libpq] Bulk ingest with result set is not supported");
+ InternalAdbcSetError(error, "%s",
+ "[libpq] Bulk ingest with result set is not supported");
return ADBC_STATUS_NOT_IMPLEMENTED;
}
@@ -645,8 +653,8 @@ AdbcStatusCode PostgresStatement::ExecuteIngest(struct ArrowArrayStream* stream,
RAISE_STATUS(error, result_helper.Execute());
auto it = result_helper.begin();
if (it == result_helper.end()) {
- SetError(error,
- "[libpq] PostgreSQL returned no rows for 'SELECT CURRENT_SCHEMA()'");
+ InternalAdbcSetError(
+ error, "[libpq] PostgreSQL returned no rows for 'SELECT CURRENT_SCHEMA()'");
return ADBC_STATUS_INTERNAL;
}
current_schema = (*it)[0].data;
@@ -717,7 +725,7 @@ AdbcStatusCode PostgresStatement::GetOption(const char* key, char* value, size_t
result = "false";
}
} else {
- SetError(error, "[libpq] Unknown statement option '%s'", key);
+ InternalAdbcSetError(error, "[libpq] Unknown statement option '%s'", key);
return ADBC_STATUS_NOT_FOUND;
}
@@ -731,13 +739,13 @@ AdbcStatusCode PostgresStatement::GetOption(const char* key, char* value, size_t
AdbcStatusCode PostgresStatement::GetOptionBytes(const char* key, uint8_t* value,
size_t* length,
struct AdbcError* error) {
- SetError(error, "[libpq] Unknown statement option '%s'", key);
+ InternalAdbcSetError(error, "[libpq] Unknown statement option '%s'", key);
return ADBC_STATUS_NOT_FOUND;
}
AdbcStatusCode PostgresStatement::GetOptionDouble(const char* key, double* value,
struct AdbcError* error) {
- SetError(error, "[libpq] Unknown statement option '%s'", key);
+ InternalAdbcSetError(error, "[libpq] Unknown statement option '%s'", key);
return ADBC_STATUS_NOT_FOUND;
}
@@ -748,7 +756,7 @@ AdbcStatusCode PostgresStatement::GetOptionInt(const char* key, int64_t* value,
*value = reader_->batch_size_hint_bytes_;
return ADBC_STATUS_OK;
}
- SetError(error, "[libpq] Unknown statement option '%s'", key);
+ InternalAdbcSetError(error, "[libpq] Unknown statement option '%s'", key);
return ADBC_STATUS_NOT_FOUND;
}
@@ -759,7 +767,7 @@ AdbcStatusCode PostgresStatement::GetParameterSchema(struct ArrowSchema* schema,
AdbcStatusCode PostgresStatement::Prepare(struct AdbcError* error) {
if (query_.empty()) {
- SetError(error, "%s", "[libpq] Must SetSqlQuery() before Prepare()");
+ InternalAdbcSetError(error, "%s", "[libpq] Must SetSqlQuery() before Prepare()");
return ADBC_STATUS_INVALID_STATE;
}
@@ -810,7 +818,8 @@ AdbcStatusCode PostgresStatement::SetOption(const char* key, const char* value,
} else if (std::strcmp(value, ADBC_INGEST_OPTION_MODE_CREATE_APPEND) == 0) {
ingest_.mode = IngestMode::kCreateAppend;
} else {
- SetError(error, "[libpq] Invalid value '%s' for option '%s'", value, key);
+ InternalAdbcSetError(error, "[libpq] Invalid value '%s' for option '%s'", value,
+ key);
return ADBC_STATUS_INVALID_ARGUMENT;
}
prepared_ = false;
@@ -823,14 +832,16 @@ AdbcStatusCode PostgresStatement::SetOption(const char* key, const char* value,
} else if (std::strcmp(value, ADBC_OPTION_VALUE_DISABLED) == 0) {
ingest_.temporary = false;
} else {
- SetError(error, "[libpq] Invalid value '%s' for option '%s'", value, key);
+ InternalAdbcSetError(error, "[libpq] Invalid value '%s' for option '%s'", value,
+ key);
return ADBC_STATUS_INVALID_ARGUMENT;
}
prepared_ = false;
} else if (std::strcmp(key, ADBC_POSTGRESQL_OPTION_BATCH_SIZE_HINT_BYTES) == 0) {
int64_t int_value = std::atol(value);
if (int_value <= 0) {
- SetError(error, "[libpq] Invalid value '%s' for option '%s'", value, key);
+ InternalAdbcSetError(error, "[libpq] Invalid value '%s' for option '%s'", value,
+ key);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -841,11 +852,12 @@ AdbcStatusCode PostgresStatement::SetOption(const char* key, const char* value,
} else if (std::strcmp(value, ADBC_OPTION_VALUE_DISABLED) == 0) {
use_copy_ = false;
} else {
- SetError(error, "[libpq] Invalid value '%s' for option '%s'", value, key);
+ InternalAdbcSetError(error, "[libpq] Invalid value '%s' for option '%s'", value,
+ key);
return ADBC_STATUS_INVALID_ARGUMENT;
}
} else {
- SetError(error, "[libpq] Unknown statement option '%s'", key);
+ InternalAdbcSetError(error, "[libpq] Unknown statement option '%s'", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
return ADBC_STATUS_OK;
@@ -853,13 +865,13 @@ AdbcStatusCode PostgresStatement::SetOption(const char* key, const char* value,
AdbcStatusCode PostgresStatement::SetOptionBytes(const char* key, const uint8_t* value,
size_t length, struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown statement option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown statement option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
AdbcStatusCode PostgresStatement::SetOptionDouble(const char* key, double value,
struct AdbcError* error) {
- SetError(error, "%s%s", "[libpq] Unknown statement option ", key);
+ InternalAdbcSetError(error, "%s%s", "[libpq] Unknown statement option ", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
@@ -867,14 +879,15 @@ AdbcStatusCode PostgresStatement::SetOptionInt(const char* key, int64_t value,
struct AdbcError* error) {
if (std::strcmp(key, ADBC_POSTGRESQL_OPTION_BATCH_SIZE_HINT_BYTES) == 0) {
if (value <= 0) {
- SetError(error, "[libpq] Invalid value '%" PRIi64 "' for option '%s'", value, key);
+ InternalAdbcSetError(error, "[libpq] Invalid value '%" PRIi64 "' for option '%s'",
+ value, key);
return ADBC_STATUS_INVALID_ARGUMENT;
}
this->batch_size_hint_bytes_ = this->reader_->batch_size_hint_bytes_ = value;
return ADBC_STATUS_OK;
}
- SetError(error, "[libpq] Unknown statement option '%s'", key);
+ InternalAdbcSetError(error, "[libpq] Unknown statement option '%s'", key);
return ADBC_STATUS_NOT_IMPLEMENTED;
}
diff --git a/c/driver/sqlite/statement_reader.c b/c/driver/sqlite/statement_reader.c
index 54c3655212..9eb65d48d4 100644
--- a/c/driver/sqlite/statement_reader.c
+++ b/c/driver/sqlite/statement_reader.c
@@ -40,21 +40,21 @@ AdbcStatusCode InternalAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
if (status != 0) {
const char* message = binder->params.get_last_error(&binder->params);
if (!message) message = "(unknown error)";
- SetError(error, "Failed to get parameter schema: (%d) %s: %s", status,
- strerror(status), message);
+ InternalAdbcSetError(error, "Failed to get parameter schema: (%d) %s: %s", status,
+ strerror(status), message);
return ADBC_STATUS_INVALID_ARGUMENT;
}
struct ArrowError arrow_error = {0};
status = ArrowArrayViewInitFromSchema(&binder->batch, &binder->schema, &arrow_error);
if (status != 0) {
- SetError(error, "Failed to initialize array view: (%d) %s: %s", status,
- strerror(status), arrow_error.message);
+ InternalAdbcSetError(error, "Failed to initialize array view: (%d) %s: %s", status,
+ strerror(status), arrow_error.message);
return ADBC_STATUS_INVALID_ARGUMENT;
}
if (binder->batch.storage_type != NANOARROW_TYPE_STRUCT) {
- SetError(error, "Bind parameters do not have root type STRUCT");
+ InternalAdbcSetError(error, "Bind parameters do not have root type STRUCT");
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -65,13 +65,13 @@ AdbcStatusCode InternalAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
for (int i = 0; i < binder->schema.n_children; i++) {
status = ArrowSchemaViewInit(&view, binder->schema.children[i], &arrow_error);
if (status != NANOARROW_OK) {
- SetError(error, "Failed to parse schema for column %d: %s (%d): %s", i,
- strerror(status), status, arrow_error.message);
+ InternalAdbcSetError(error, "Failed to parse schema for column %d: %s (%d): %s", i,
+ strerror(status), status, arrow_error.message);
return ADBC_STATUS_INVALID_ARGUMENT;
}
if (view.type == NANOARROW_TYPE_UNINITIALIZED) {
- SetError(error, "Column %d has UNINITIALIZED type", i);
+ InternalAdbcSetError(error, "Column %d has UNINITIALIZED type", i);
return ADBC_STATUS_INTERNAL;
}
@@ -80,8 +80,9 @@ AdbcStatusCode InternalAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
status = ArrowSchemaViewInit(&value_view, binder->schema.children[i]->dictionary,
&arrow_error);
if (status != NANOARROW_OK) {
- SetError(error, "Failed to parse schema for column %d->dictionary: %s (%d): %s",
- i, strerror(status), status, arrow_error.message);
+ InternalAdbcSetError(
+ error, "Failed to parse schema for column %d->dictionary: %s (%d): %s", i,
+ strerror(status), status, arrow_error.message);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -96,8 +97,8 @@ AdbcStatusCode InternalAdbcSqliteBinderSet(struct AdbcSqliteBinder* binder,
case NANOARROW_TYPE_BINARY_VIEW:
break;
default:
- SetError(error, "Column %d dictionary has unsupported type %s", i,
- ArrowTypeString(value_view.type));
+ InternalAdbcSetError(error, "Column %d dictionary has unsupported type %s", i,
+ ArrowTypeString(value_view.type));
return ADBC_STATUS_NOT_IMPLEMENTED;
}
}
@@ -129,7 +130,7 @@ static AdbcStatusCode ArrowDate32ToIsoString(int32_t value, char** buf,
#if SIZEOF_TIME_T < 8
if ((value > INT32_MAX / SECONDS_PER_DAY) || (value < INT32_MIN / SECONDS_PER_DAY)) {
- SetError(error, "Date %" PRId32 " exceeds platform time_t bounds", value);
+ InternalAdbcSetError(error, "Date %" PRId32 " exceeds platform time_t bounds", value);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -142,13 +143,15 @@ static AdbcStatusCode ArrowDate32ToIsoString(int32_t value, char** buf,
#if defined(_WIN32)
if (gmtime_s(&broken_down_time, &time) != 0) {
- SetError(error, "Could not convert date %" PRId32 " to broken down time", value);
+ InternalAdbcSetError(error, "Could not convert date %" PRId32 " to broken down time",
+ value);
return ADBC_STATUS_INVALID_ARGUMENT;
}
#else
if (gmtime_r(&time, &broken_down_time) != &broken_down_time) {
- SetError(error, "Could not convert date %" PRId32 " to broken down time", value);
+ InternalAdbcSetError(error, "Could not convert date %" PRId32 " to broken down time",
+ value);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -160,7 +163,8 @@ static AdbcStatusCode ArrowDate32ToIsoString(int32_t value, char** buf,
}
if (strftime(tsstr, strlen + 1, "%Y-%m-%d", &broken_down_time) == 0) {
- SetError(error, "Call to strftime for date %" PRId32 " with failed", value);
+ InternalAdbcSetError(error, "Call to strftime for date %" PRId32 " with failed",
+ value);
free(tsstr);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -206,8 +210,9 @@ static AdbcStatusCode ArrowTimestampToIsoString(int64_t value, enum ArrowTimeUni
#if SIZEOF_TIME_T < 8
if ((seconds > INT32_MAX) || (seconds < INT32_MIN)) {
- SetError(error, "Timestamp %" PRId64 " with unit %d exceeds platform time_t bounds",
- value, unit);
+ InternalAdbcSetError(
+ error, "Timestamp %" PRId64 " with unit %d exceeds platform time_t bounds", value,
+ unit);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -220,17 +225,17 @@ static AdbcStatusCode ArrowTimestampToIsoString(int64_t value, enum ArrowTimeUni
#if defined(_WIN32)
if (gmtime_s(&broken_down_time, &time) != 0) {
- SetError(error,
- "Could not convert timestamp %" PRId64 " with unit %d to broken down time",
- value, unit);
+ InternalAdbcSetError(
+ error, "Could not convert timestamp %" PRId64 " with unit %d to broken down time",
+ value, unit);
return ADBC_STATUS_INVALID_ARGUMENT;
}
#else
if (gmtime_r(&time, &broken_down_time) != &broken_down_time) {
- SetError(error,
- "Could not convert timestamp %" PRId64 " with unit %d to broken down time",
- value, unit);
+ InternalAdbcSetError(
+ error, "Could not convert timestamp %" PRId64 " with unit %d to broken down time",
+ value, unit);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -242,8 +247,9 @@ static AdbcStatusCode ArrowTimestampToIsoString(int64_t value, enum ArrowTimeUni
}
if (strftime(tsstr, strlen, "%Y-%m-%dT%H:%M:%S", &broken_down_time) == 0) {
- SetError(error, "Call to strftime for timestamp %" PRId64 " with unit %d failed",
- value, unit);
+ InternalAdbcSetError(error,
+ "Call to strftime for timestamp %" PRId64 " with unit %d failed",
+ value, unit);
free(tsstr);
return ADBC_STATUS_INVALID_ARGUMENT;
}
@@ -283,8 +289,8 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
status =
ArrowArrayViewInitFromSchema(&binder->batch, &binder->schema, &arrow_error);
if (status != 0) {
- SetError(error, "Failed to initialize array view: (%d) %s: %s", status,
- strerror(status), arrow_error.message);
+ InternalAdbcSetError(error, "Failed to initialize array view: (%d) %s: %s",
+ status, strerror(status), arrow_error.message);
return ADBC_STATUS_INTERNAL;
}
}
@@ -293,8 +299,8 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
if (status != 0) {
const char* message = binder->params.get_last_error(&binder->params);
if (!message) message = "(unknown error)";
- SetError(error, "Failed to get next parameter batch: (%d) %s: %s", status,
- strerror(status), message);
+ InternalAdbcSetError(error, "Failed to get next parameter batch: (%d) %s: %s",
+ status, strerror(status), message);
return ADBC_STATUS_IO;
}
@@ -306,8 +312,8 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
status = ArrowArrayViewSetArray(&binder->batch, &binder->array, &arrow_error);
if (status != 0) {
- SetError(error, "Failed to initialize array view: (%d) %s: %s", status,
- strerror(status), arrow_error.message);
+ InternalAdbcSetError(error, "Failed to initialize array view: (%d) %s: %s", status,
+ strerror(status), arrow_error.message);
return ADBC_STATUS_INTERNAL;
}
@@ -315,11 +321,12 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
}
if (sqlite3_reset(stmt) != SQLITE_OK) {
- SetError(error, "Failed to reset statement: %s", sqlite3_errmsg(conn));
+ InternalAdbcSetError(error, "Failed to reset statement: %s", sqlite3_errmsg(conn));
return ADBC_STATUS_INTERNAL;
}
if (sqlite3_clear_bindings(stmt) != SQLITE_OK) {
- SetError(error, "Failed to clear statement bindings: %s", sqlite3_errmsg(conn));
+ InternalAdbcSetError(error, "Failed to clear statement bindings: %s",
+ sqlite3_errmsg(conn));
return ADBC_STATUS_INTERNAL;
}
@@ -346,10 +353,10 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
uint64_t value =
ArrowArrayViewGetUIntUnsafe(binder->batch.children[col], binder->next_row);
if (value > INT64_MAX) {
- SetError(error,
- "Column %d has unsigned integer value %" PRIu64
- "out of range of int64_t",
- col, value);
+ InternalAdbcSetError(error,
+ "Column %d has unsigned integer value %" PRIu64
+ "out of range of int64_t",
+ col, value);
return ADBC_STATUS_INVALID_ARGUMENT;
}
status = sqlite3_bind_int64(stmt, col + 1, (int64_t)value);
@@ -401,11 +408,11 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
char* tsstr;
if ((value > INT32_MAX) || (value < INT32_MIN)) {
- SetError(error,
- "Column %d has value %" PRId64
- " which exceeds the expected range "
- "for an Arrow DATE32 type",
- col, value);
+ InternalAdbcSetError(error,
+ "Column %d has value %" PRId64
+ " which exceeds the expected range "
+ "for an Arrow DATE32 type",
+ col, value);
return ADBC_STATUS_INVALID_DATA;
}
@@ -435,14 +442,15 @@ AdbcStatusCode InternalAdbcSqliteBinderBindNext(struct AdbcSqliteBinder* binder,
break;
}
default:
- SetError(error, "Column %d has unsupported type %s", col,
- ArrowTypeString(binder->types[col]));
+ InternalAdbcSetError(error, "Column %d has unsupported type %s", col,
+ ArrowTypeString(binder->types[col]));
return ADBC_STATUS_NOT_IMPLEMENTED;
}
}
if (status != SQLITE_OK) {
- SetError(error, "Failed to clear statement bindings: %s", sqlite3_errmsg(conn));
+ InternalAdbcSetError(error, "Failed to clear statement bindings: %s",
+ sqlite3_errmsg(conn));
return ADBC_STATUS_INTERNAL;
}
}
@@ -491,7 +499,8 @@ const char* InternalSqliteStatementReaderGetLastError(struct ArrowArrayStream* s
return reader->error.message;
}
-void InternalSqliteStatementReaderSetError(struct InternalSqliteStatementReader* reader) {
+void InternalSqliteStatementReaderInternalAdbcSetError(
+ struct InternalSqliteStatementReader* reader) {
const char* msg = sqlite3_errmsg(reader->db);
// Reset here so that we don't get an error again in StatementRelease
(void)sqlite3_reset(reader->stmt);
@@ -684,12 +693,12 @@ int InternalSqliteStatementReaderGetNext(struct ArrowArrayStream* self,
} else if (rc == SQLITE_ERROR) {
reader->done = 1;
status = EIO;
- InternalSqliteStatementReaderSetError(reader);
+ InternalSqliteStatementReaderInternalAdbcSetError(reader);
break;
} else if (rc != SQLITE_ROW) {
reader->done = 1;
status = ADBC_STATUS_INTERNAL;
- InternalSqliteStatementReaderSetError(reader);
+ InternalSqliteStatementReaderInternalAdbcSetError(reader);
break;
}
@@ -816,7 +825,8 @@ AdbcStatusCode InternalSqliteStatementReaderInferFinalize(
if (current_type[col] == NANOARROW_TYPE_STRING ||
current_type[col] == NANOARROW_TYPE_BINARY) {
if (binary[col].data == NULL) {
- SetError(error, "INTERNAL: column has binary-like type but no backing buffer");
+ InternalAdbcSetError(
+ error, "INTERNAL: column has binary-like type but no backing buffer");
return ADBC_STATUS_INTERNAL;
}
}
@@ -871,13 +881,13 @@ AdbcStatusCode InternalSqliteStatementReaderAppendInt64ToBinary(
while (1) {
written = snprintf(output, buffer_size, "%" PRId64, value);
if (written < 0) {
- SetError(error, "Encoding error when upcasting double to string");
+ InternalAdbcSetError(error, "Encoding error when upcasting double to string");
return ADBC_STATUS_INTERNAL;
} else if (((size_t)written) >= buffer_size) {
// Truncated, resize and try again
// Check for overflow - presumably this can never happen...?
if (UINT_MAX - buffer_size < buffer_size) {
- SetError(error, "Overflow when upcasting double to string");
+ InternalAdbcSetError(error, "Overflow when upcasting double to string");
return ADBC_STATUS_INTERNAL;
}
CHECK_NA(INTERNAL, ArrowBufferReserve(binary, buffer_size), error);
@@ -903,13 +913,13 @@ AdbcStatusCode InternalSqliteStatementReaderAppendDoubleToBinary(
while (1) {
written = snprintf(output, buffer_size, "%e", value);
if (written < 0) {
- SetError(error, "Encoding error when upcasting double to string");
+ InternalAdbcSetError(error, "Encoding error when upcasting double to string");
return ADBC_STATUS_INTERNAL;
} else if (((size_t)written) >= buffer_size) {
// Truncated, resize and try again
// Check for overflow - presumably this can never happen...?
if (UINT_MAX - buffer_size < buffer_size) {
- SetError(error, "Overflow when upcasting double to string");
+ InternalAdbcSetError(error, "Overflow when upcasting double to string");
return ADBC_STATUS_INTERNAL;
}
CHECK_NA(INTERNAL, ArrowBufferReserve(binary, buffer_size), error);
@@ -1185,7 +1195,7 @@ AdbcStatusCode InternalAdbcSqliteExportReader(sqlite3* db, sqlite3_stmt* stmt,
}
continue;
} else if (rc == SQLITE_ERROR) {
- SetError(error, "Failed to step query: %s", sqlite3_errmsg(db));
+ InternalAdbcSetError(error, "Failed to step query: %s", sqlite3_errmsg(db));
status = ADBC_STATUS_IO;
// Reset here so that we don't get an error again in StatementRelease
(void)sqlite3_reset(stmt);
From fc0aa11f1611b3e33a4d831b26eb39bc05be702e Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 10:41:57 +0900
Subject: [PATCH 05/16] Add headers for entrypoints
---
.pre-commit-config.yaml | 2 +-
c/CMakeLists.txt | 10 ++++++
c/include/arrow-adbc/driver/bigquery.h | 40 ++++++++++++++++++++++
c/include/arrow-adbc/driver/flightsql.h | 41 +++++++++++++++++++++++
c/include/arrow-adbc/driver/postgresql.h | 42 ++++++++++++++++++++++++
c/include/arrow-adbc/driver/snowflake.h | 41 +++++++++++++++++++++++
c/include/arrow-adbc/driver/sqlite.h | 40 ++++++++++++++++++++++
c/integration/static_test/main.c | 11 +++----
c/symbols.map | 1 +
9 files changed, 221 insertions(+), 7 deletions(-)
create mode 100644 c/include/arrow-adbc/driver/bigquery.h
create mode 100644 c/include/arrow-adbc/driver/flightsql.h
create mode 100644 c/include/arrow-adbc/driver/postgresql.h
create mode 100644 c/include/arrow-adbc/driver/snowflake.h
create mode 100644 c/include/arrow-adbc/driver/sqlite.h
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 9289142cbe..afcab0e181 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -114,7 +114,7 @@ repos:
name: Ensure CGO adbc.h is syncd
language: script
pass_filenames: true
- files: '^c/include/arrow-adbc/.*\.h$'
+ files: '^c/include/arrow-adbc/[^/]*\.h$'
entry: "./ci/scripts/run_cgo_drivermgr_check.sh"
# https://infra.apache.org/github-actions-policy.html
- id: check-pin
diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt
index 036645ebd8..2ad7faacfa 100644
--- a/c/CMakeLists.txt
+++ b/c/CMakeLists.txt
@@ -64,6 +64,8 @@ if(ADBC_INTEGRATION_DUCKDB)
endif()
if(ADBC_DRIVER_FLIGHTSQL)
+ install(FILES "${REPOSITORY_ROOT}/c/include/arrow-adbc/driver/flightsql.h"
+ DESTINATION include/arrow-adbc/driver)
add_subdirectory(driver/flightsql)
endif()
@@ -75,18 +77,26 @@ if(ADBC_DRIVER_MANAGER)
endif()
if(ADBC_DRIVER_POSTGRESQL)
+ install(FILES "${REPOSITORY_ROOT}/c/include/arrow-adbc/driver/postgresql.h"
+ DESTINATION include/arrow-adbc/driver)
add_subdirectory(driver/postgresql)
endif()
if(ADBC_DRIVER_SQLITE)
+ install(FILES "${REPOSITORY_ROOT}/c/include/arrow-adbc/driver/sqlite.h"
+ DESTINATION include/arrow-adbc/driver)
add_subdirectory(driver/sqlite)
endif()
if(ADBC_DRIVER_SNOWFLAKE)
+ install(FILES "${REPOSITORY_ROOT}/c/include/arrow-adbc/driver/snowflake.h"
+ DESTINATION include/arrow-adbc/driver)
add_subdirectory(driver/snowflake)
endif()
if(ADBC_DRIVER_BIGQUERY)
+ install(FILES "${REPOSITORY_ROOT}/c/include/arrow-adbc/driver/bigquery.h"
+ DESTINATION include/arrow-adbc/driver)
add_subdirectory(driver/bigquery)
endif()
diff --git a/c/include/arrow-adbc/driver/bigquery.h b/c/include/arrow-adbc/driver/bigquery.h
new file mode 100644
index 0000000000..00305446ac
--- /dev/null
+++ b/c/include/arrow-adbc/driver/bigquery.h
@@ -0,0 +1,40 @@
+// 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.
+
+/// \file arrow-adbc/driver/bigquery.h ADBC BigQuery Driver
+///
+/// A driver for BigQuery.
+
+#pragma once
+
+#ifndef ADBC_DRIVER_BIGQUERY_H
+#define ADBC_DRIVER_BIGQUERY_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ADBC_EXPORT
+AdbcStatusCode BigQueryDriverInit(int version, void* raw_driver, struct AdbcError* error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/c/include/arrow-adbc/driver/flightsql.h b/c/include/arrow-adbc/driver/flightsql.h
new file mode 100644
index 0000000000..0689eb13fb
--- /dev/null
+++ b/c/include/arrow-adbc/driver/flightsql.h
@@ -0,0 +1,41 @@
+// 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.
+
+/// \file arrow-adbc/driver/flightsql.h ADBC Flight SQL Driver
+///
+/// A driver for Arrow Flight SQL.
+
+#pragma once
+
+#ifndef ADBC_DRIVER_FLIGHTSQL_H
+#define ADBC_DRIVER_FLIGHTSQL_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ADBC_EXPORT
+AdbcStatusCode FlightSQLDriverInit(int version, void* raw_driver,
+ struct AdbcError* error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/c/include/arrow-adbc/driver/postgresql.h b/c/include/arrow-adbc/driver/postgresql.h
new file mode 100644
index 0000000000..6f2fce6da9
--- /dev/null
+++ b/c/include/arrow-adbc/driver/postgresql.h
@@ -0,0 +1,42 @@
+// 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.
+
+/// \file arrow-adbc/adbc_driver_manager.h ADBC Driver Manager
+///
+/// A helper library to dynamically load and use multiple ADBC drivers in the
+/// same process.
+
+#pragma once
+
+#ifndef ADBC_DRIVER_POSTGRESQL_H
+#define ADBC_DRIVER_POSTGRESQL_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ADBC_EXPORT
+AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
+ struct AdbcError* error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/c/include/arrow-adbc/driver/snowflake.h b/c/include/arrow-adbc/driver/snowflake.h
new file mode 100644
index 0000000000..caf606f799
--- /dev/null
+++ b/c/include/arrow-adbc/driver/snowflake.h
@@ -0,0 +1,41 @@
+// 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.
+
+/// \file arrow-adbc/driver/snowflake.h ADBC Snowflake Driver
+///
+/// A driver for Snowflake.
+
+#pragma once
+
+#ifndef ADBC_DRIVER_SNOWFLAKE_H
+#define ADBC_DRIVER_SNOWFLAKE_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ADBC_EXPORT
+AdbcStatusCode SnowflakeDriverInit(int version, void* raw_driver,
+ struct AdbcError* error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/c/include/arrow-adbc/driver/sqlite.h b/c/include/arrow-adbc/driver/sqlite.h
new file mode 100644
index 0000000000..c538cd5b6a
--- /dev/null
+++ b/c/include/arrow-adbc/driver/sqlite.h
@@ -0,0 +1,40 @@
+// 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.
+
+/// \file arrow-adbc/driver/sqlite.h ADBC SQLite Driver
+///
+/// A driver for SQLite.
+
+#pragma once
+
+#ifndef ADBC_DRIVER_SQLITE_H
+#define ADBC_DRIVER_SQLITE_H
+
+#include
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ADBC_EXPORT
+AdbcStatusCode SqliteDriverInit(int version, void* raw_driver, struct AdbcError* error);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/c/integration/static_test/main.c b/c/integration/static_test/main.c
index 91d0ab0ed8..4cd9cdc991 100644
--- a/c/integration/static_test/main.c
+++ b/c/integration/static_test/main.c
@@ -20,12 +20,11 @@
#include
#include
-
-AdbcStatusCode FlightSQLDriverInit(int version, void* raw_driver,
- struct AdbcError* error);
-AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
- struct AdbcError* error);
-AdbcStatusCode SqliteDriverInit(int version, void* raw_driver, struct AdbcError* error);
+#include
+#include
+#include
+#include
+#include
int main(int argc, char** argv) {
struct AdbcError error;
diff --git a/c/symbols.map b/c/symbols.map
index 37128424f4..6c49f301f5 100644
--- a/c/symbols.map
+++ b/c/symbols.map
@@ -23,6 +23,7 @@
InternalAdbc*;
# Expose driver-specific initialization routines
+ BigQueryDriverInit;
FlightSQLDriverInit;
PostgresqlDriverInit;
SnowflakeDriverInit;
From c3003bc1f5fc2eb67cfbeacf26010c050212a731 Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 11:17:16 +0900
Subject: [PATCH 06/16] Fix typo in path
---
ci/scripts/cpp_static_test.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ci/scripts/cpp_static_test.sh b/ci/scripts/cpp_static_test.sh
index d86cde334e..4114d4fcfd 100755
--- a/ci/scripts/cpp_static_test.sh
+++ b/ci/scripts/cpp_static_test.sh
@@ -114,9 +114,9 @@ main() {
cmake "${source_dir}/c/integration/static_test" \
-DCMAKE_PREFIX_PATH="${install_dir}" \
-DCMAKE_VERBOSE_MAKEFILE=ON
- cmake --build "${build_dir}" --target static_test
+ cmake --build "${build_dir}/test" --target static_test
- "${build_dir}/static_test"
+ "${build_dir}/test/static_test"
popd
}
From f1304f29f4c2e5fcbb86399f15e2c5432d048ae9 Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 12:38:22 +0900
Subject: [PATCH 07/16] fix python-debug
---
.github/workflows/nightly-verify.yml | 2 +-
compose.yaml | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/nightly-verify.yml b/.github/workflows/nightly-verify.yml
index 5acb64f457..ca0fbc5969 100644
--- a/.github/workflows/nightly-verify.yml
+++ b/.github/workflows/nightly-verify.yml
@@ -209,7 +209,7 @@ jobs:
- name: python-debug
run: |
pushd arrow-adbc
- env PYTHON=3.13 docker compose run --rm python-debug
+ docker compose run -e PYTHON=3.13 --rm python-debug
source-verify-docker:
name: "Verify Source (OS)/${{ matrix.os }} ${{ matrix.version }}"
diff --git a/compose.yaml b/compose.yaml
index 26dac01c0d..d25f0df967 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -108,11 +108,11 @@ services:
command: "/bin/bash -c '/adbc/ci/scripts/python_conda_test.sh /adbc /adbc/build'"
python-debug:
- image: ${REPO}:${ARCH}-python-${PYTHON}-debug-adbc
+ image: ${REPO}:${ARCH}-python-debug-adbc
build:
context: .
cache_from:
- - ${REPO}:${ARCH}-python-${PYTHON}-debug-adbc
+ - ${REPO}:${ARCH}-python-debug-adbc
dockerfile: ci/docker/python-debug.dockerfile
args:
ARCH: ${ARCH}
From af5bbd5e4fe3a6af7e99d07396a9f8ec83217315 Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 25 Apr 2025 15:07:02 +0900
Subject: [PATCH 08/16] fix python-debug (for real!?)
---
.github/workflows/nightly-verify.yml | 3 +++
ci/docker/python-debug.dockerfile | 2 +-
ci/docker/python-debug.sh | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/nightly-verify.yml b/.github/workflows/nightly-verify.yml
index ca0fbc5969..3206747e8a 100644
--- a/.github/workflows/nightly-verify.yml
+++ b/.github/workflows/nightly-verify.yml
@@ -208,6 +208,9 @@ jobs:
- name: python-debug
run: |
+ # Need to set this or ASAN inside the container gets stuck
+ # printing a loop of DEADLYSIGNAL
+ sudo sysctl vm.mmap_rnd_bits=28
pushd arrow-adbc
docker compose run -e PYTHON=3.13 --rm python-debug
diff --git a/ci/docker/python-debug.dockerfile b/ci/docker/python-debug.dockerfile
index c17ca103dd..d687e5368f 100644
--- a/ci/docker/python-debug.dockerfile
+++ b/ci/docker/python-debug.dockerfile
@@ -15,7 +15,7 @@
# specific language governing permissions and limitations
# under the License.
-FROM ghcr.io/mamba-org/micromamba:bookworm
+FROM ghcr.io/mamba-org/micromamba:debian-slim
ARG ARCH
ARG GO
diff --git a/ci/docker/python-debug.sh b/ci/docker/python-debug.sh
index cf03c988d9..6012093dd7 100755
--- a/ci/docker/python-debug.sh
+++ b/ci/docker/python-debug.sh
@@ -31,7 +31,7 @@ cat /adbc/ci/conda_env_cpp.txt /adbc/ci/conda_env_python.txt |\
micromamba install -c conda-forge -y \
-f /tmp/spec.txt \
- "conda-forge/label/python_debug::python=${PYTHON}[build=*_cpython]"
+ "conda-forge/label/python_debug::python=${PYTHON}.*"
micromamba clean --all -y
export ADBC_USE_ASAN=ON
From 7f8bfbae1e918935e4942ab2835b2e0de1d1ddbc Mon Sep 17 00:00:00 2001
From: David Li
Date: Mon, 28 Apr 2025 22:44:22 +0900
Subject: [PATCH 09/16] Remove redundant include guard
---
c/include/arrow-adbc/driver/bigquery.h | 5 -----
c/include/arrow-adbc/driver/flightsql.h | 5 -----
c/include/arrow-adbc/driver/postgresql.h | 5 -----
c/include/arrow-adbc/driver/snowflake.h | 5 -----
c/include/arrow-adbc/driver/sqlite.h | 5 -----
5 files changed, 25 deletions(-)
diff --git a/c/include/arrow-adbc/driver/bigquery.h b/c/include/arrow-adbc/driver/bigquery.h
index 00305446ac..be4e283615 100644
--- a/c/include/arrow-adbc/driver/bigquery.h
+++ b/c/include/arrow-adbc/driver/bigquery.h
@@ -21,9 +21,6 @@
#pragma once
-#ifndef ADBC_DRIVER_BIGQUERY_H
-#define ADBC_DRIVER_BIGQUERY_H
-
#include
#ifdef __cplusplus
@@ -36,5 +33,3 @@ AdbcStatusCode BigQueryDriverInit(int version, void* raw_driver, struct AdbcErro
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/c/include/arrow-adbc/driver/flightsql.h b/c/include/arrow-adbc/driver/flightsql.h
index 0689eb13fb..a1a0473f30 100644
--- a/c/include/arrow-adbc/driver/flightsql.h
+++ b/c/include/arrow-adbc/driver/flightsql.h
@@ -21,9 +21,6 @@
#pragma once
-#ifndef ADBC_DRIVER_FLIGHTSQL_H
-#define ADBC_DRIVER_FLIGHTSQL_H
-
#include
#ifdef __cplusplus
@@ -37,5 +34,3 @@ AdbcStatusCode FlightSQLDriverInit(int version, void* raw_driver,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/c/include/arrow-adbc/driver/postgresql.h b/c/include/arrow-adbc/driver/postgresql.h
index 6f2fce6da9..0f1faf5e6b 100644
--- a/c/include/arrow-adbc/driver/postgresql.h
+++ b/c/include/arrow-adbc/driver/postgresql.h
@@ -22,9 +22,6 @@
#pragma once
-#ifndef ADBC_DRIVER_POSTGRESQL_H
-#define ADBC_DRIVER_POSTGRESQL_H
-
#include
#ifdef __cplusplus
@@ -38,5 +35,3 @@ AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/c/include/arrow-adbc/driver/snowflake.h b/c/include/arrow-adbc/driver/snowflake.h
index caf606f799..f5fe0f6819 100644
--- a/c/include/arrow-adbc/driver/snowflake.h
+++ b/c/include/arrow-adbc/driver/snowflake.h
@@ -21,9 +21,6 @@
#pragma once
-#ifndef ADBC_DRIVER_SNOWFLAKE_H
-#define ADBC_DRIVER_SNOWFLAKE_H
-
#include
#ifdef __cplusplus
@@ -37,5 +34,3 @@ AdbcStatusCode SnowflakeDriverInit(int version, void* raw_driver,
#ifdef __cplusplus
}
#endif
-
-#endif
diff --git a/c/include/arrow-adbc/driver/sqlite.h b/c/include/arrow-adbc/driver/sqlite.h
index c538cd5b6a..76191aa629 100644
--- a/c/include/arrow-adbc/driver/sqlite.h
+++ b/c/include/arrow-adbc/driver/sqlite.h
@@ -21,9 +21,6 @@
#pragma once
-#ifndef ADBC_DRIVER_SQLITE_H
-#define ADBC_DRIVER_SQLITE_H
-
#include
#ifdef __cplusplus
@@ -36,5 +33,3 @@ AdbcStatusCode SqliteDriverInit(int version, void* raw_driver, struct AdbcError*
#ifdef __cplusplus
}
#endif
-
-#endif
From 6bb1dda396153c82da2282eed4d51939529f72e9 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 10:56:32 +0900
Subject: [PATCH 10/16] Apply suggestions from code review
Co-authored-by: Sutou Kouhei
---
c/cmake_modules/GoUtils.cmake | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/c/cmake_modules/GoUtils.cmake b/c/cmake_modules/GoUtils.cmake
index 2342a33934..f1a2fb9a4c 100644
--- a/c/cmake_modules/GoUtils.cmake
+++ b/c/cmake_modules/GoUtils.cmake
@@ -135,14 +135,11 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME)
"${GO_BUILD_FLAGS} $<$:-gcflags=\"-N -l\">")
# if we're building debug mode then change the default CGO_CFLAGS and CGO_CXXFLAGS from "-g O2" to "-g3"
- set(GO_FLAGS)
- if(CMAKE_BUILD_TYPE STREQUAL "Debug")
- set(GO_FLAGS "-g3")
- endif()
+ set(GO_FLAGS "$<$:-g3>")
string(JOIN " " GO_FLAGS "${GO_FLAGS}")
foreach(DEFINE ${ARG_DEFINES})
- list(APPEND GO_FLAGS "-D${DEFINE}")
+ string(APPEND GO_FLAGS " -D${DEFINE}")
endforeach()
set(GO_ENV_VARS)
From 74a7dc5bbf06ad98d7622934321d46dd987f9cf1 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 11:30:22 +0900
Subject: [PATCH 11/16] fix
---
c/cmake_modules/GoUtils.cmake | 2 --
1 file changed, 2 deletions(-)
diff --git a/c/cmake_modules/GoUtils.cmake b/c/cmake_modules/GoUtils.cmake
index f1a2fb9a4c..9311d08dd3 100644
--- a/c/cmake_modules/GoUtils.cmake
+++ b/c/cmake_modules/GoUtils.cmake
@@ -136,8 +136,6 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME)
# if we're building debug mode then change the default CGO_CFLAGS and CGO_CXXFLAGS from "-g O2" to "-g3"
set(GO_FLAGS "$<$:-g3>")
- string(JOIN " " GO_FLAGS "${GO_FLAGS}")
-
foreach(DEFINE ${ARG_DEFINES})
string(APPEND GO_FLAGS " -D${DEFINE}")
endforeach()
From 92ce999db0864640857f34764fc020fc0a3821c1 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 15:09:32 +0900
Subject: [PATCH 12/16] can't have quotes with generator expression
---
c/cmake_modules/GoUtils.cmake | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/c/cmake_modules/GoUtils.cmake b/c/cmake_modules/GoUtils.cmake
index 9311d08dd3..20ce95e8eb 100644
--- a/c/cmake_modules/GoUtils.cmake
+++ b/c/cmake_modules/GoUtils.cmake
@@ -142,8 +142,8 @@ function(add_go_lib GO_MOD_DIR GO_LIBNAME)
set(GO_ENV_VARS)
list(APPEND GO_ENV_VARS "CGO_ENABLED=1")
- list(APPEND GO_ENV_VARS "CGO_CFLAGS=\"${GO_FLAGS}\"")
- list(APPEND GO_ENV_VARS "CGO_CXXFLAGS=\"${GO_FLAGS}\"")
+ list(APPEND GO_ENV_VARS "CGO_CFLAGS=${GO_FLAGS}")
+ list(APPEND GO_ENV_VARS "CGO_CXXFLAGS=${GO_FLAGS}")
if(BUILD_SHARED)
set(LIB_NAME_SHARED
From 35d1fb76383c3ecf5113d3eb23c6bbbc7cc09bc7 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 15:54:13 +0900
Subject: [PATCH 13/16] rename to be consistent
---
.github/workflows/nightly-verify.yml | 5 +
c/driver/postgresql/postgresql.cc | 4 +-
c/include/arrow-adbc/adbc_driver_manager.h | 5 +-
c/include/arrow-adbc/driver/bigquery.h | 3 +-
c/include/arrow-adbc/driver/flightsql.h | 4 +-
c/include/arrow-adbc/driver/postgresql.h | 9 +-
c/include/arrow-adbc/driver/snowflake.h | 4 +-
c/include/arrow-adbc/driver/sqlite.h | 3 +-
c/integration/shared_test/CMakeLists.txt | 27 ++++++
c/integration/shared_test/main.c | 95 +++++++++++++++++++
c/integration/static_test/main.c | 6 +-
c/symbols.map | 7 --
.../cpp_shared_no_common_entrypoints_test.sh | 95 +++++++++++++++++++
compose.yaml | 9 +-
.../arrow-adbc/adbc_driver_manager.h | 5 +-
go/adbc/pkg/_tmpl/driver.go.tmpl | 4 +-
go/adbc/pkg/bigquery/driver.go | 4 +-
go/adbc/pkg/flightsql/driver.go | 4 +-
go/adbc/pkg/snowflake/driver.go | 4 +-
19 files changed, 261 insertions(+), 36 deletions(-)
create mode 100644 c/integration/shared_test/CMakeLists.txt
create mode 100644 c/integration/shared_test/main.c
create mode 100755 ci/scripts/cpp_shared_no_common_entrypoints_test.sh
diff --git a/.github/workflows/nightly-verify.yml b/.github/workflows/nightly-verify.yml
index 3206747e8a..4d27fe661f 100644
--- a/.github/workflows/nightly-verify.yml
+++ b/.github/workflows/nightly-verify.yml
@@ -201,6 +201,11 @@ jobs:
pushd arrow-adbc
docker compose run --rm cpp-gcc-latest
+ - name: cpp-shared-no-common-entrypoints-test
+ run: |
+ pushd arrow-adbc
+ docker compose run --rm cpp-shared-no-common-entrypoints-test
+
- name: cpp-static-test
run: |
pushd arrow-adbc
diff --git a/c/driver/postgresql/postgresql.cc b/c/driver/postgresql/postgresql.cc
index 95e8ce7804..5d25a6e1fa 100644
--- a/c/driver/postgresql/postgresql.cc
+++ b/c/driver/postgresql/postgresql.cc
@@ -881,8 +881,8 @@ AdbcStatusCode AdbcStatementSetSqlQuery(struct AdbcStatement* statement,
extern "C" {
ADBC_EXPORT
-AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
- struct AdbcError* error) {
+AdbcStatusCode AdbcDriverPostgresqlInit(int version, void* raw_driver,
+ struct AdbcError* error) {
if (version != ADBC_VERSION_1_0_0 && version != ADBC_VERSION_1_1_0) {
return ADBC_STATUS_NOT_IMPLEMENTED;
}
diff --git a/c/include/arrow-adbc/adbc_driver_manager.h b/c/include/arrow-adbc/adbc_driver_manager.h
index c32368ab69..e5e9bf67c4 100644
--- a/c/include/arrow-adbc/adbc_driver_manager.h
+++ b/c/include/arrow-adbc/adbc_driver_manager.h
@@ -40,8 +40,9 @@ extern "C" {
///
/// \param[in] driver_name An identifier for the driver (e.g. a path to a
/// shared library on Linux).
-/// \param[in] entrypoint An identifier for the entrypoint (e.g. the
-/// symbol to call for AdbcDriverInitFunc on Linux).
+/// \param[in] entrypoint An identifier for the entrypoint (e.g. the symbol to
+/// call for AdbcDriverInitFunc on Linux). If not provided, search for an
+/// entrypoint based on the driver name.
/// \param[in] version The ADBC revision to attempt to initialize.
/// \param[out] driver The table of function pointers to initialize.
/// \param[out] error An optional location to return an error message
diff --git a/c/include/arrow-adbc/driver/bigquery.h b/c/include/arrow-adbc/driver/bigquery.h
index be4e283615..985a021400 100644
--- a/c/include/arrow-adbc/driver/bigquery.h
+++ b/c/include/arrow-adbc/driver/bigquery.h
@@ -28,7 +28,8 @@ extern "C" {
#endif
ADBC_EXPORT
-AdbcStatusCode BigQueryDriverInit(int version, void* raw_driver, struct AdbcError* error);
+AdbcStatusCode AdbcDriverBigqueryInit(int version, void* raw_driver,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/include/arrow-adbc/driver/flightsql.h b/c/include/arrow-adbc/driver/flightsql.h
index a1a0473f30..1d2ad8e2d1 100644
--- a/c/include/arrow-adbc/driver/flightsql.h
+++ b/c/include/arrow-adbc/driver/flightsql.h
@@ -28,8 +28,8 @@ extern "C" {
#endif
ADBC_EXPORT
-AdbcStatusCode FlightSQLDriverInit(int version, void* raw_driver,
- struct AdbcError* error);
+AdbcStatusCode AdbcDriverFlightsqlInit(int version, void* raw_driver,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/include/arrow-adbc/driver/postgresql.h b/c/include/arrow-adbc/driver/postgresql.h
index 0f1faf5e6b..49ea63e16f 100644
--- a/c/include/arrow-adbc/driver/postgresql.h
+++ b/c/include/arrow-adbc/driver/postgresql.h
@@ -15,10 +15,9 @@
// specific language governing permissions and limitations
// under the License.
-/// \file arrow-adbc/adbc_driver_manager.h ADBC Driver Manager
+/// \file arrow-adbc/driver/postgresql.h ADBC PostgreSQL Driver
///
-/// A helper library to dynamically load and use multiple ADBC drivers in the
-/// same process.
+/// A driver for PostgreSQL.
#pragma once
@@ -29,8 +28,8 @@ extern "C" {
#endif
ADBC_EXPORT
-AdbcStatusCode PostgresqlDriverInit(int version, void* raw_driver,
- struct AdbcError* error);
+AdbcStatusCode AdbcDriverPostgresqlInit(int version, void* raw_driver,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/include/arrow-adbc/driver/snowflake.h b/c/include/arrow-adbc/driver/snowflake.h
index f5fe0f6819..3dc734bd41 100644
--- a/c/include/arrow-adbc/driver/snowflake.h
+++ b/c/include/arrow-adbc/driver/snowflake.h
@@ -28,8 +28,8 @@ extern "C" {
#endif
ADBC_EXPORT
-AdbcStatusCode SnowflakeDriverInit(int version, void* raw_driver,
- struct AdbcError* error);
+AdbcStatusCode AdbcDriverSnowflakeInit(int version, void* raw_driver,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/include/arrow-adbc/driver/sqlite.h b/c/include/arrow-adbc/driver/sqlite.h
index 76191aa629..e11c8418b9 100644
--- a/c/include/arrow-adbc/driver/sqlite.h
+++ b/c/include/arrow-adbc/driver/sqlite.h
@@ -28,7 +28,8 @@ extern "C" {
#endif
ADBC_EXPORT
-AdbcStatusCode SqliteDriverInit(int version, void* raw_driver, struct AdbcError* error);
+AdbcStatusCode AdbcDriverSqliteInit(int version, void* raw_driver,
+ struct AdbcError* error);
#ifdef __cplusplus
}
diff --git a/c/integration/shared_test/CMakeLists.txt b/c/integration/shared_test/CMakeLists.txt
new file mode 100644
index 0000000000..dabe629c71
--- /dev/null
+++ b/c/integration/shared_test/CMakeLists.txt
@@ -0,0 +1,27 @@
+# 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.
+
+cmake_minimum_required(VERSION 3.18)
+
+project(adbc-static-test LANGUAGES C)
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+
+find_package(AdbcDriverManager REQUIRED)
+
+add_executable(shared_test main.c)
+target_link_libraries(shared_test PRIVATE AdbcDriverManager::adbc_driver_manager_shared)
diff --git a/c/integration/shared_test/main.c b/c/integration/shared_test/main.c
new file mode 100644
index 0000000000..351d2a5d06
--- /dev/null
+++ b/c/integration/shared_test/main.c
@@ -0,0 +1,95 @@
+// 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
+#include
+#include
+
+#include
+#include
+
+int TryDriver(const char* driver_name) {
+ struct AdbcError error;
+ struct AdbcDriver driver;
+
+ memset(&error, 0, sizeof(error));
+ memset(&driver, 0, sizeof(driver));
+
+ AdbcStatusCode status =
+ AdbcLoadDriver(driver_name, NULL, ADBC_VERSION_1_1_0, &driver, &error);
+ if (status != ADBC_STATUS_OK) {
+ if (error.release) {
+ fprintf(stderr, "AdbcLoadDriver failed: %s\n", error.message);
+ error.release(&error);
+ } else {
+ fprintf(stderr, "AdbcLoadDriver failed\n");
+ }
+ return EXIT_FAILURE;
+ }
+
+ if (driver.release) {
+ status = driver.release(&driver, &error);
+
+ if (status != ADBC_STATUS_OK) {
+ if (error.release) {
+ fprintf(stderr, "AdbcDriver.release failed: %s\n", error.message);
+ error.release(&error);
+ } else {
+ fprintf(stderr, "AdbcDriver.release failed\n");
+ }
+ return EXIT_FAILURE;
+ }
+ }
+
+ return EXIT_SUCCESS;
+}
+
+int main(int argc, char** argv) {
+ int rc = 0;
+
+ rc = TryDriver("adbc_driver_bigquery");
+ if (rc != EXIT_SUCCESS) {
+ return rc;
+ }
+ printf("Loaded BigQuery driver\n");
+
+ rc = TryDriver("adbc_driver_flightsql");
+ if (rc != EXIT_SUCCESS) {
+ return rc;
+ }
+ printf("Loaded FlightSQL driver\n");
+
+ rc = TryDriver("adbc_driver_postgresql");
+ if (rc != EXIT_SUCCESS) {
+ return rc;
+ }
+ printf("Loaded PostgreSQL driver\n");
+
+ rc = TryDriver("adbc_driver_snowflake");
+ if (rc != EXIT_SUCCESS) {
+ return rc;
+ }
+ printf("Loaded Snowflake driver\n");
+
+ rc = TryDriver("adbc_driver_sqlite");
+ if (rc != EXIT_SUCCESS) {
+ return rc;
+ }
+ printf("Loaded SQLite driver\n");
+
+ return EXIT_SUCCESS;
+}
diff --git a/c/integration/static_test/main.c b/c/integration/static_test/main.c
index 4cd9cdc991..c6b19fdca3 100644
--- a/c/integration/static_test/main.c
+++ b/c/integration/static_test/main.c
@@ -40,7 +40,7 @@ int main(int argc, char** argv) {
AdbcStatusCode status;
- status = FlightSQLDriverInit(ADBC_VERSION_1_1_0, &flightsql, &error);
+ status = AdbcDriverFlightsqlInit(ADBC_VERSION_1_1_0, &flightsql, &error);
if (status != ADBC_STATUS_OK) {
if (error.release) {
fprintf(stderr, "FlightSQLDriverInit failed: %s\n", error.message);
@@ -51,7 +51,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- status = PostgresqlDriverInit(ADBC_VERSION_1_1_0, &postgresql, &error);
+ status = AdbcDriverPostgresqlInit(ADBC_VERSION_1_1_0, &postgresql, &error);
if (status != ADBC_STATUS_OK) {
if (error.release) {
fprintf(stderr, "PostgresqlDriverInit failed: %s\n", error.message);
@@ -62,7 +62,7 @@ int main(int argc, char** argv) {
return EXIT_FAILURE;
}
- status = SqliteDriverInit(ADBC_VERSION_1_1_0, &sqlite, &error);
+ status = AdbcDriverSqliteInit(ADBC_VERSION_1_1_0, &sqlite, &error);
if (status != ADBC_STATUS_OK) {
if (error.release) {
fprintf(stderr, "SqliteDriverInit failed: %s\n", error.message);
diff --git a/c/symbols.map b/c/symbols.map
index 6c49f301f5..9adf7bcb99 100644
--- a/c/symbols.map
+++ b/c/symbols.map
@@ -22,13 +22,6 @@
# Needed for tests, but namespaced so they are clearly not for public use
InternalAdbc*;
- # Expose driver-specific initialization routines
- BigQueryDriverInit;
- FlightSQLDriverInit;
- PostgresqlDriverInit;
- SnowflakeDriverInit;
- SqliteDriverInit;
-
extern "C++" {
Adbc*;
};
diff --git a/ci/scripts/cpp_shared_no_common_entrypoints_test.sh b/ci/scripts/cpp_shared_no_common_entrypoints_test.sh
new file mode 100755
index 0000000000..55e900172d
--- /dev/null
+++ b/ci/scripts/cpp_shared_no_common_entrypoints_test.sh
@@ -0,0 +1,95 @@
+#!/usr/bin/env bash
+# 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.
+
+# Test building a simple application using the static drivers, ensuring that
+# symbols do not clash and all dependencies are present.
+# https://github.com/apache/arrow-adbc/issues/2562
+
+set -euo pipefail
+
+main() {
+ local -r source_dir="${1}"
+ local -r build_dir="${2}"
+ local -r install_dir="${3}"
+
+ mkdir -p "${build_dir}"
+
+ echo "Install ADBC"
+ mkdir -p "${build_dir}/install"
+ pushd "${build_dir}/install"
+ env \
+ ADBC_BUILD_SHARED=ON \
+ ADBC_BUILD_STATIC=OFF \
+ ADBC_BUILD_TESTS=OFF \
+ ADBC_USE_ASAN=OFF \
+ ADBC_USE_UBSAN=OFF \
+ ADBC_CMAKE_ARGS="-DADBC_DEFINE_COMMON_ENTRYPOINTS=OFF" \
+ "${source_dir}/ci/scripts/cpp_build.sh" \
+ "${source_dir}" \
+ "${build_dir}/install" \
+ "${install_dir}"
+ popd
+
+ # No static libraries should exist
+ if find "${install_dir}" | grep -E "libadbc.*\.a"; then
+ echo "Found ADBC static libraries, which should not exist for this test"
+ return 1
+ fi
+
+ # Make sure Adbc symbols aren't exported
+ failed=0
+ for lib in "${install_dir}/lib"/libadbc_driver_*.so; do
+ echo "Checking symbols in $lib"
+ if [[ $(basename "$lib") == *"adbc_driver_manager"* ]]; then
+ continue
+ fi
+
+ nm \
+ --defined-only \
+ --demangle \
+ --extern-only \
+ --no-weak \
+ "${lib}" | \
+ grep ' T ' | \
+ awk '{print $3}' | \
+ { grep --extended-regexp '^Adbc' || true; } | \
+ { grep --extended-regexp --invert-match '^AdbcDriver[a-zA-Z]+Init' || true; } \
+ > /tmp/symbols.txt
+ if [[ -s /tmp/symbols.txt ]]; then
+ echo "Found unexpected exported Adbc* symbols in $lib"
+ cat /tmp/symbols.txt
+ failed=$(($failed + 1))
+ fi
+ done
+ if [[ $failed -ne 0 ]]; then
+ return $failed
+ fi
+
+ echo "Build test application"
+ mkdir -p "${build_dir}/test"
+ pushd "${build_dir}/test"
+ cmake "${source_dir}/c/integration/shared_test" \
+ -DCMAKE_PREFIX_PATH="${install_dir}" \
+ -DCMAKE_VERBOSE_MAKEFILE=ON
+ cmake --build "${build_dir}/test" --target shared_test
+
+ env LD_LIBRARY_PATH="${install_dir}/lib" "${build_dir}/test/shared_test"
+ popd
+}
+
+main "$@"
diff --git a/compose.yaml b/compose.yaml
index d25f0df967..bcf85726ff 100644
--- a/compose.yaml
+++ b/compose.yaml
@@ -56,12 +56,19 @@ services:
- .:/adbc:delegated
command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_build.sh /adbc /adbc/build/gcc-latest && env BUILD_ALL=0 BUILD_DRIVER_MANAGER=1 BUILD_DRIVER_SQLITE=1 /adbc/ci/scripts/cpp_test.sh /adbc/build/gcc-latest'"
+ # Build and dynamically load shared drivers missing the common entrypoints
+ cpp-shared-no-common-entrypoints-test:
+ image: ${REPO}:${ARCH}-cpp-clang-latest-adbc
+ volumes:
+ - .:/adbc:delegated
+ command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_shared_no_common_entrypoints_test.sh /adbc /adbc/build/shared-test/build /adbc/build/shared-test/local'"
+
# Test building and installing the static libraries, then try linking to them.
cpp-static-test:
image: ${REPO}:${ARCH}-cpp-clang-latest-adbc
volumes:
- .:/adbc:delegated
- command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_static_test.sh /adbc /adbc/build/static-test /adbc/build/local'"
+ command: "bash -c 'git config --global --add safe.directory /adbc && /adbc/ci/scripts/cpp_static_test.sh /adbc /adbc/build/static-test/build /adbc/build/static-test/local'"
############################ Documentation ###################################
diff --git a/go/adbc/drivermgr/arrow-adbc/adbc_driver_manager.h b/go/adbc/drivermgr/arrow-adbc/adbc_driver_manager.h
index c32368ab69..e5e9bf67c4 100644
--- a/go/adbc/drivermgr/arrow-adbc/adbc_driver_manager.h
+++ b/go/adbc/drivermgr/arrow-adbc/adbc_driver_manager.h
@@ -40,8 +40,9 @@ extern "C" {
///
/// \param[in] driver_name An identifier for the driver (e.g. a path to a
/// shared library on Linux).
-/// \param[in] entrypoint An identifier for the entrypoint (e.g. the
-/// symbol to call for AdbcDriverInitFunc on Linux).
+/// \param[in] entrypoint An identifier for the entrypoint (e.g. the symbol to
+/// call for AdbcDriverInitFunc on Linux). If not provided, search for an
+/// entrypoint based on the driver name.
/// \param[in] version The ADBC revision to attempt to initialize.
/// \param[out] driver The table of function pointers to initialize.
/// \param[out] error An optional location to return an error message
diff --git a/go/adbc/pkg/_tmpl/driver.go.tmpl b/go/adbc/pkg/_tmpl/driver.go.tmpl
index bbede3b3c3..0eec1fcc10 100644
--- a/go/adbc/pkg/_tmpl/driver.go.tmpl
+++ b/go/adbc/pkg/_tmpl/driver.go.tmpl
@@ -1810,8 +1810,8 @@ func {{.Prefix}}StatementExecutePartitions(stmt *C.struct_AdbcStatement, schema
return C.ADBC_STATUS_OK
}
-//export {{.Prefix}}DriverInit
-func {{.Prefix}}DriverInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
+//export AdbcDriver{{.Prefix}}Init
+func AdbcDriver{{.Prefix}}Init(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
driver := (*C.struct_AdbcDriver)(unsafe.Pointer(rawDriver))
switch version {
diff --git a/go/adbc/pkg/bigquery/driver.go b/go/adbc/pkg/bigquery/driver.go
index 4f119dded7..53bb5b5f10 100644
--- a/go/adbc/pkg/bigquery/driver.go
+++ b/go/adbc/pkg/bigquery/driver.go
@@ -1813,8 +1813,8 @@ func BigQueryStatementExecutePartitions(stmt *C.struct_AdbcStatement, schema *C.
return C.ADBC_STATUS_OK
}
-//export BigQueryDriverInit
-func BigQueryDriverInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
+//export AdbcDriverBigqueryInit
+func AdbcDriverBigqueryInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
driver := (*C.struct_AdbcDriver)(unsafe.Pointer(rawDriver))
switch version {
diff --git a/go/adbc/pkg/flightsql/driver.go b/go/adbc/pkg/flightsql/driver.go
index 57e3a55462..037130cf41 100644
--- a/go/adbc/pkg/flightsql/driver.go
+++ b/go/adbc/pkg/flightsql/driver.go
@@ -1813,8 +1813,8 @@ func FlightSQLStatementExecutePartitions(stmt *C.struct_AdbcStatement, schema *C
return C.ADBC_STATUS_OK
}
-//export FlightSQLDriverInit
-func FlightSQLDriverInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
+//export AdbcDriverFlightsqlInit
+func AdbcDriverFlightsqlInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
driver := (*C.struct_AdbcDriver)(unsafe.Pointer(rawDriver))
switch version {
diff --git a/go/adbc/pkg/snowflake/driver.go b/go/adbc/pkg/snowflake/driver.go
index 47147481a0..5d4175fcc3 100644
--- a/go/adbc/pkg/snowflake/driver.go
+++ b/go/adbc/pkg/snowflake/driver.go
@@ -1813,8 +1813,8 @@ func SnowflakeStatementExecutePartitions(stmt *C.struct_AdbcStatement, schema *C
return C.ADBC_STATUS_OK
}
-//export SnowflakeDriverInit
-func SnowflakeDriverInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
+//export AdbcDriverSnowflakeInit
+func AdbcDriverSnowflakeInit(version C.int, rawDriver *C.void, err *C.struct_AdbcError) C.AdbcStatusCode {
driver := (*C.struct_AdbcDriver)(unsafe.Pointer(rawDriver))
switch version {
From 7ecc1ecb18677e2df64ad67786a30cf923604c17 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 16:16:49 +0900
Subject: [PATCH 14/16] fix names
---
c/driver/postgresql/postgresql_test.cc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/c/driver/postgresql/postgresql_test.cc b/c/driver/postgresql/postgresql_test.cc
index f37bb6eba5..444ce4941c 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -233,12 +233,12 @@ TEST_F(PostgresDatabaseTest, AdbcDriverBackwardsCompatibility) {
std::memset(&driver, 0, ADBC_DRIVER_1_1_0_SIZE);
driver.ErrorGetDetailCount = Canary;
- ASSERT_THAT(::PostgresqlDriverInit(ADBC_VERSION_1_0_0, &driver, &error),
+ ASSERT_THAT(::AdbcDriverPostgresqlInit(ADBC_VERSION_1_0_0, &driver, &error),
IsOkStatus(&error));
ASSERT_EQ(Canary, driver.ErrorGetDetailCount);
- ASSERT_THAT(::PostgresqlDriverInit(424242, &driver, &error),
+ ASSERT_THAT(::AdbcDriverPostgresqlInit(424242, &driver, &error),
IsStatus(ADBC_STATUS_NOT_IMPLEMENTED, &error));
}
From d3c1d5362168279720801dd3323b5f03e735f1c1 Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 16:26:12 +0900
Subject: [PATCH 15/16] fix names
---
c/driver/flightsql/sqlite_flightsql_test.cc | 9 +++------
c/driver/postgresql/database.h | 7 -------
c/driver/postgresql/postgresql.cc | 2 +-
c/driver/postgresql/postgresql_test.cc | 3 ++-
go/adbc/pkg/_tmpl/utils.c.tmpl | 2 +-
go/adbc/pkg/_tmpl/utils.h.tmpl | 2 +-
go/adbc/pkg/bigquery/utils.c | 2 +-
go/adbc/pkg/bigquery/utils.h | 3 ++-
go/adbc/pkg/flightsql/utils.c | 2 +-
go/adbc/pkg/flightsql/utils.h | 3 ++-
go/adbc/pkg/snowflake/utils.c | 2 +-
go/adbc/pkg/snowflake/utils.h | 3 ++-
12 files changed, 17 insertions(+), 23 deletions(-)
diff --git a/c/driver/flightsql/sqlite_flightsql_test.cc b/c/driver/flightsql/sqlite_flightsql_test.cc
index 033467b7f4..dfe9776bd7 100644
--- a/c/driver/flightsql/sqlite_flightsql_test.cc
+++ b/c/driver/flightsql/sqlite_flightsql_test.cc
@@ -23,6 +23,7 @@
#include
#include
+#include
#include
#include
#include
@@ -35,10 +36,6 @@
using adbc_validation::IsOkErrno;
using adbc_validation::IsOkStatus;
-extern "C" {
-AdbcStatusCode FlightSQLDriverInit(int, void*, struct AdbcError*);
-}
-
#define CHECK_OK(EXPR) \
do { \
if (auto adbc_status = (EXPR); adbc_status != ADBC_STATUS_OK) { \
@@ -244,12 +241,12 @@ TEST_F(SqliteFlightSqlTest, AdbcDriverBackwardsCompatibility) {
std::memset(&driver, 0, ADBC_DRIVER_1_1_0_SIZE);
driver.ErrorGetDetailCount = Canary;
- ASSERT_THAT(::FlightSQLDriverInit(ADBC_VERSION_1_0_0, &driver, &error),
+ ASSERT_THAT(::AdbcDriverFlightsqlInit(ADBC_VERSION_1_0_0, &driver, &error),
IsOkStatus(&error));
ASSERT_EQ(Canary, driver.ErrorGetDetailCount);
- ASSERT_THAT(::FlightSQLDriverInit(424242, &driver, &error),
+ ASSERT_THAT(::AdbcDriverFlightsqlInit(424242, &driver, &error),
adbc_validation::IsStatus(ADBC_STATUS_NOT_IMPLEMENTED, &error));
}
diff --git a/c/driver/postgresql/database.h b/c/driver/postgresql/database.h
index e0a00267e3..5adf3af9a6 100644
--- a/c/driver/postgresql/database.h
+++ b/c/driver/postgresql/database.h
@@ -87,10 +87,3 @@ class PostgresDatabase {
std::array redshift_server_version_{};
};
} // namespace adbcpq
-
-extern "C" {
-/// For applications that want to use the driver struct directly, this gives
-/// them access to the Init routine.
-ADBC_EXPORT
-AdbcStatusCode PostgresqlDriverInit(int, void*, struct AdbcError*);
-}
diff --git a/c/driver/postgresql/postgresql.cc b/c/driver/postgresql/postgresql.cc
index 5d25a6e1fa..858c743789 100644
--- a/c/driver/postgresql/postgresql.cc
+++ b/c/driver/postgresql/postgresql.cc
@@ -962,7 +962,7 @@ AdbcStatusCode AdbcDriverPostgresqlInit(int version, void* raw_driver,
#if !defined(ADBC_NO_COMMON_ENTRYPOINTS)
ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* raw_driver, struct AdbcError* error) {
- return PostgresqlDriverInit(version, raw_driver, error);
+ return AdbcDriverPostgresqlInit(version, raw_driver, error);
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
}
diff --git a/c/driver/postgresql/postgresql_test.cc b/c/driver/postgresql/postgresql_test.cc
index 444ce4941c..fec2302c1e 100644
--- a/c/driver/postgresql/postgresql_test.cc
+++ b/c/driver/postgresql/postgresql_test.cc
@@ -28,13 +28,14 @@
#include
#include
+#include
#include
#include
#include
+#include
#include "common/options.h"
#include "common/utils.h"
-#include "database.h"
#include "validation/adbc_validation.h"
#include "validation/adbc_validation_util.h"
diff --git a/go/adbc/pkg/_tmpl/utils.c.tmpl b/go/adbc/pkg/_tmpl/utils.c.tmpl
index b941f2224a..08a039facf 100644
--- a/go/adbc/pkg/_tmpl/utils.c.tmpl
+++ b/go/adbc/pkg/_tmpl/utils.c.tmpl
@@ -429,7 +429,7 @@ AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement,
ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
- return {{.Prefix}}DriverInit(version, driver, error);
+ return AdbcDriver{{.Prefix}}Init(version, driver, error);
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
diff --git a/go/adbc/pkg/_tmpl/utils.h.tmpl b/go/adbc/pkg/_tmpl/utils.h.tmpl
index 15d862f462..b8d9a039ab 100644
--- a/go/adbc/pkg/_tmpl/utils.h.tmpl
+++ b/go/adbc/pkg/_tmpl/utils.h.tmpl
@@ -81,7 +81,7 @@ AdbcStatusCode {{.Prefix}}StatementSetOptionInt(struct AdbcStatement*, const cha
AdbcStatusCode {{.Prefix}}StatementSetSqlQuery(struct AdbcStatement* stmt, const char* query, struct AdbcError* err);
AdbcStatusCode {{.Prefix}}StatementSetSubstraitPlan(struct AdbcStatement* stmt, const uint8_t* plan, size_t length, struct AdbcError* err);
-AdbcStatusCode {{.Prefix}}DriverInit(int version, void* rawDriver, struct AdbcError* err);
+AdbcStatusCode AdbcDriver{{.Prefix}}Init(int version, void* rawDriver, struct AdbcError* err);
static inline void {{.Prefix}}errRelease(struct AdbcError* error) {
if (error->release) {
diff --git a/go/adbc/pkg/bigquery/utils.c b/go/adbc/pkg/bigquery/utils.c
index e5f97ca7a0..9e126e6283 100644
--- a/go/adbc/pkg/bigquery/utils.c
+++ b/go/adbc/pkg/bigquery/utils.c
@@ -431,7 +431,7 @@ AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement,
ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
- return BigQueryDriverInit(version, driver, error);
+ return AdbcDriverBigqueryInit(version, driver, error);
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
diff --git a/go/adbc/pkg/bigquery/utils.h b/go/adbc/pkg/bigquery/utils.h
index 6e2b96d86d..6f7fd345d8 100644
--- a/go/adbc/pkg/bigquery/utils.h
+++ b/go/adbc/pkg/bigquery/utils.h
@@ -156,7 +156,8 @@ AdbcStatusCode BigQueryStatementSetSubstraitPlan(struct AdbcStatement* stmt,
const uint8_t* plan, size_t length,
struct AdbcError* err);
-AdbcStatusCode BigQueryDriverInit(int version, void* rawDriver, struct AdbcError* err);
+AdbcStatusCode AdbcDriverBigqueryInit(int version, void* rawDriver,
+ struct AdbcError* err);
static inline void BigQueryerrRelease(struct AdbcError* error) {
if (error->release) {
diff --git a/go/adbc/pkg/flightsql/utils.c b/go/adbc/pkg/flightsql/utils.c
index 46cc5d2d85..d98d24a13d 100644
--- a/go/adbc/pkg/flightsql/utils.c
+++ b/go/adbc/pkg/flightsql/utils.c
@@ -431,7 +431,7 @@ AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement,
ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
- return FlightSQLDriverInit(version, driver, error);
+ return AdbcDriverFlightsqlInit(version, driver, error);
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
diff --git a/go/adbc/pkg/flightsql/utils.h b/go/adbc/pkg/flightsql/utils.h
index 8c26c8439f..37494ddb63 100644
--- a/go/adbc/pkg/flightsql/utils.h
+++ b/go/adbc/pkg/flightsql/utils.h
@@ -154,7 +154,8 @@ AdbcStatusCode FlightSQLStatementSetSubstraitPlan(struct AdbcStatement* stmt,
const uint8_t* plan, size_t length,
struct AdbcError* err);
-AdbcStatusCode FlightSQLDriverInit(int version, void* rawDriver, struct AdbcError* err);
+AdbcStatusCode AdbcDriverFlightsqlInit(int version, void* rawDriver,
+ struct AdbcError* err);
static inline void FlightSQLerrRelease(struct AdbcError* error) {
if (error->release) {
diff --git a/go/adbc/pkg/snowflake/utils.c b/go/adbc/pkg/snowflake/utils.c
index 67ae1046db..52b5ecab1f 100644
--- a/go/adbc/pkg/snowflake/utils.c
+++ b/go/adbc/pkg/snowflake/utils.c
@@ -431,7 +431,7 @@ AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement,
ADBC_EXPORT
AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error) {
- return SnowflakeDriverInit(version, driver, error);
+ return AdbcDriverSnowflakeInit(version, driver, error);
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
diff --git a/go/adbc/pkg/snowflake/utils.h b/go/adbc/pkg/snowflake/utils.h
index 8268caabac..812786ea35 100644
--- a/go/adbc/pkg/snowflake/utils.h
+++ b/go/adbc/pkg/snowflake/utils.h
@@ -154,7 +154,8 @@ AdbcStatusCode SnowflakeStatementSetSubstraitPlan(struct AdbcStatement* stmt,
const uint8_t* plan, size_t length,
struct AdbcError* err);
-AdbcStatusCode SnowflakeDriverInit(int version, void* rawDriver, struct AdbcError* err);
+AdbcStatusCode AdbcDriverSnowflakeInit(int version, void* rawDriver,
+ struct AdbcError* err);
static inline void SnowflakeerrRelease(struct AdbcError* error) {
if (error->release) {
From 87ad465f5c2324583933db3505c04eecc7ca156f Mon Sep 17 00:00:00 2001
From: David Li
Date: Tue, 29 Apr 2025 16:54:43 +0900
Subject: [PATCH 16/16] more renaming, add alias for compatibility
---
c/integration/static_test/main.c | 12 ++++++------
.../Interop/FlightSql/FlightSqlDriverLoader.cs | 2 +-
.../Interop/Snowflake/SnowflakeDriverLoader.cs | 2 +-
csharp/test/Drivers/Interop/Snowflake/readme.md | 2 +-
go/adbc/pkg/bigquery/utils.c | 6 ++++++
go/adbc/pkg/bigquery/utils.h | 1 +
go/adbc/pkg/flightsql/utils.c | 6 ++++++
go/adbc/pkg/flightsql/utils.h | 1 +
go/adbc/pkg/snowflake/utils.c | 6 ++++++
go/adbc/pkg/snowflake/utils.h | 1 +
r/adbcsqlite/src/init.cc | 5 +++--
rust/driver/snowflake/src/driver.rs | 4 ++--
12 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/c/integration/static_test/main.c b/c/integration/static_test/main.c
index c6b19fdca3..101e00f508 100644
--- a/c/integration/static_test/main.c
+++ b/c/integration/static_test/main.c
@@ -43,10 +43,10 @@ int main(int argc, char** argv) {
status = AdbcDriverFlightsqlInit(ADBC_VERSION_1_1_0, &flightsql, &error);
if (status != ADBC_STATUS_OK) {
if (error.release) {
- fprintf(stderr, "FlightSQLDriverInit failed: %s\n", error.message);
+ fprintf(stderr, "AdbcDriverFlightsqlInit failed: %s\n", error.message);
error.release(&error);
} else {
- fprintf(stderr, "FlightSQLDriverInit failed\n");
+ fprintf(stderr, "AdbcDriverFlightsqlInit failed\n");
}
return EXIT_FAILURE;
}
@@ -54,10 +54,10 @@ int main(int argc, char** argv) {
status = AdbcDriverPostgresqlInit(ADBC_VERSION_1_1_0, &postgresql, &error);
if (status != ADBC_STATUS_OK) {
if (error.release) {
- fprintf(stderr, "PostgresqlDriverInit failed: %s\n", error.message);
+ fprintf(stderr, "AdbcDriverPostgresqlInit failed: %s\n", error.message);
error.release(&error);
} else {
- fprintf(stderr, "PostgresqlDriverInit failed\n");
+ fprintf(stderr, "AdbcDriverPostgresqlInit failed\n");
}
return EXIT_FAILURE;
}
@@ -65,10 +65,10 @@ int main(int argc, char** argv) {
status = AdbcDriverSqliteInit(ADBC_VERSION_1_1_0, &sqlite, &error);
if (status != ADBC_STATUS_OK) {
if (error.release) {
- fprintf(stderr, "SqliteDriverInit failed: %s\n", error.message);
+ fprintf(stderr, "AdbcDriverSqliteInit failed: %s\n", error.message);
error.release(&error);
} else {
- fprintf(stderr, "SqliteDriverInit failed\n");
+ fprintf(stderr, "AdbcDriverSqliteInit failed\n");
}
return EXIT_FAILURE;
}
diff --git a/csharp/src/Drivers/Interop/FlightSql/FlightSqlDriverLoader.cs b/csharp/src/Drivers/Interop/FlightSql/FlightSqlDriverLoader.cs
index 12ea491d92..ef090d4fd2 100644
--- a/csharp/src/Drivers/Interop/FlightSql/FlightSqlDriverLoader.cs
+++ b/csharp/src/Drivers/Interop/FlightSql/FlightSqlDriverLoader.cs
@@ -22,7 +22,7 @@ namespace Apache.Arrow.Adbc.Drivers.Interop.FlightSql
///
public class FlightSqlDriverLoader : AdbcDriverLoader
{
- public FlightSqlDriverLoader() : base("libadbc_driver_flightsql", "FlightSqlDriverInit")
+ public FlightSqlDriverLoader() : base("libadbc_driver_flightsql", "AdbcDriverFlightsqlInit")
{
}
diff --git a/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs b/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
index 14d85b6de0..27dfe3452f 100644
--- a/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
+++ b/csharp/src/Drivers/Interop/Snowflake/SnowflakeDriverLoader.cs
@@ -24,7 +24,7 @@ namespace Apache.Arrow.Adbc.Drivers.Interop.Snowflake
///
public class SnowflakeDriverLoader : AdbcDriverLoader
{
- public SnowflakeDriverLoader() : base("libadbc_driver_snowflake", "SnowflakeDriverInit")
+ public SnowflakeDriverLoader() : base("libadbc_driver_snowflake", "AdbcDriverSnowflakeInit")
{
}
diff --git a/csharp/test/Drivers/Interop/Snowflake/readme.md b/csharp/test/Drivers/Interop/Snowflake/readme.md
index 8e7a8877c1..a0df8aff21 100644
--- a/csharp/test/Drivers/Interop/Snowflake/readme.md
+++ b/csharp/test/Drivers/Interop/Snowflake/readme.md
@@ -30,7 +30,7 @@ The environment variable `SNOWFLAKE_TEST_CONFIG_FILE` must be set to a configura
The following values can be setup in the configuration:
- **driverPath** - The path for the Go library. Can be a relative path if using .NET 5.0 or greater, otherwise, it is an absolute path.
-- **driverEntryPoint** - The driver entry point. For Snowflake, this is `SnowflakeDriverInit`.
+- **driverEntryPoint** - The driver entry point. For Snowflake, this is `AdbcDriverSnowflakeInit`.
- **account** - The `adbc.snowflake.sql.account` value from the [Snowflake Client Options](https://arrow.apache.org/adbc/0.5.1/driver/snowflake.html#client-options).
- **user** - The Snowflake user name.
- **password** - The Snowflake password, if using `auth_snowflake` for the auth type.
diff --git a/go/adbc/pkg/bigquery/utils.c b/go/adbc/pkg/bigquery/utils.c
index 9e126e6283..a07c22f2b1 100644
--- a/go/adbc/pkg/bigquery/utils.c
+++ b/go/adbc/pkg/bigquery/utils.c
@@ -435,6 +435,12 @@ AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
+ADBC_EXPORT
+AdbcStatusCode BigQueryDriverInit(int version, void* driver, struct AdbcError* error) {
+ // For backwards compatibility
+ return AdbcDriverBigqueryInit(version, driver, error);
+}
+
int BigQueryArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int BigQueryArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
diff --git a/go/adbc/pkg/bigquery/utils.h b/go/adbc/pkg/bigquery/utils.h
index 6f7fd345d8..3eb938b9fd 100644
--- a/go/adbc/pkg/bigquery/utils.h
+++ b/go/adbc/pkg/bigquery/utils.h
@@ -158,6 +158,7 @@ AdbcStatusCode BigQueryStatementSetSubstraitPlan(struct AdbcStatement* stmt,
AdbcStatusCode AdbcDriverBigqueryInit(int version, void* rawDriver,
struct AdbcError* err);
+AdbcStatusCode BigQueryDriverInit(int version, void* rawDriver, struct AdbcError* err);
static inline void BigQueryerrRelease(struct AdbcError* error) {
if (error->release) {
diff --git a/go/adbc/pkg/flightsql/utils.c b/go/adbc/pkg/flightsql/utils.c
index d98d24a13d..f62389dcf0 100644
--- a/go/adbc/pkg/flightsql/utils.c
+++ b/go/adbc/pkg/flightsql/utils.c
@@ -435,6 +435,12 @@ AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
+ADBC_EXPORT
+AdbcStatusCode FlightSqlDriverInit(int version, void* driver, struct AdbcError* error) {
+ // For backwards compatibility
+ return AdbcDriverFlightsqlInit(version, driver, error);
+}
+
int FlightSQLArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int FlightSQLArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
diff --git a/go/adbc/pkg/flightsql/utils.h b/go/adbc/pkg/flightsql/utils.h
index 37494ddb63..0f45f3dc5b 100644
--- a/go/adbc/pkg/flightsql/utils.h
+++ b/go/adbc/pkg/flightsql/utils.h
@@ -156,6 +156,7 @@ AdbcStatusCode FlightSQLStatementSetSubstraitPlan(struct AdbcStatement* stmt,
AdbcStatusCode AdbcDriverFlightsqlInit(int version, void* rawDriver,
struct AdbcError* err);
+AdbcStatusCode FlightSqlDriverInit(int version, void* rawDriver, struct AdbcError* err);
static inline void FlightSQLerrRelease(struct AdbcError* error) {
if (error->release) {
diff --git a/go/adbc/pkg/snowflake/utils.c b/go/adbc/pkg/snowflake/utils.c
index 52b5ecab1f..46c05b6cd3 100644
--- a/go/adbc/pkg/snowflake/utils.c
+++ b/go/adbc/pkg/snowflake/utils.c
@@ -435,6 +435,12 @@ AdbcStatusCode AdbcDriverInit(int version, void* driver, struct AdbcError* error
}
#endif // ADBC_NO_COMMON_ENTRYPOINTS
+ADBC_EXPORT
+AdbcStatusCode SnowflakeDriverInit(int version, void* driver, struct AdbcError* error) {
+ // For backwards compatibility
+ return AdbcDriverSnowflakeInit(version, driver, error);
+}
+
int SnowflakeArrayStreamGetSchema(struct ArrowArrayStream*, struct ArrowSchema*);
int SnowflakeArrayStreamGetNext(struct ArrowArrayStream*, struct ArrowArray*);
diff --git a/go/adbc/pkg/snowflake/utils.h b/go/adbc/pkg/snowflake/utils.h
index 812786ea35..2942def9c8 100644
--- a/go/adbc/pkg/snowflake/utils.h
+++ b/go/adbc/pkg/snowflake/utils.h
@@ -156,6 +156,7 @@ AdbcStatusCode SnowflakeStatementSetSubstraitPlan(struct AdbcStatement* stmt,
AdbcStatusCode AdbcDriverSnowflakeInit(int version, void* rawDriver,
struct AdbcError* err);
+AdbcStatusCode SnowflakeDriverInit(int version, void* rawDriver, struct AdbcError* err);
static inline void SnowflakeerrRelease(struct AdbcError* error) {
if (error->release) {
diff --git a/r/adbcsqlite/src/init.cc b/r/adbcsqlite/src/init.cc
index 3c921c19c3..a7f51bfb38 100644
--- a/r/adbcsqlite/src/init.cc
+++ b/r/adbcsqlite/src/init.cc
@@ -22,7 +22,8 @@
#include "arrow-adbc/adbc.h"
extern "C" {
-AdbcStatusCode SqliteDriverInit(int version, void* raw_driver, struct AdbcError* error);
+AdbcStatusCode AdbcDriverSqliteInit(int version, void* raw_driver,
+ struct AdbcError* error);
static SEXP init_func_xptr = 0;
@@ -36,7 +37,7 @@ void R_init_adbcsqlite(DllInfo* dll) {
R_useDynamicSymbols(dll, FALSE);
init_func_xptr =
- PROTECT(R_MakeExternalPtrFn((DL_FUNC)SqliteDriverInit, R_NilValue, R_NilValue));
+ PROTECT(R_MakeExternalPtrFn((DL_FUNC)AdbcDriverSqliteInit, R_NilValue, R_NilValue));
Rf_setAttrib(init_func_xptr, R_ClassSymbol, Rf_mkString("adbc_driver_init_func"));
R_PreserveObject(init_func_xptr);
UNPROTECT(1);
diff --git a/rust/driver/snowflake/src/driver.rs b/rust/driver/snowflake/src/driver.rs
index 825cd61ae1..e355d3f9cd 100644
--- a/rust/driver/snowflake/src/driver.rs
+++ b/rust/driver/snowflake/src/driver.rs
@@ -39,7 +39,7 @@ pub use builder::*;
static DRIVER: LazyLock> = LazyLock::new(|| {
ManagedDriver::load_dynamic_from_name(
"adbc_driver_snowflake",
- Some(b"SnowflakeDriverInit"),
+ Some(b"AdbcDriverSnowflakeInit"),
Default::default(),
)
});
@@ -65,7 +65,7 @@ impl fmt::Debug for Driver {
#[cfg(any(feature = "bundled", feature = "linked"))]
extern "C" {
- #[link_name = "SnowflakeDriverInit"]
+ #[link_name = "AdbcDriverSnowflakeInit"]
fn init(version: c_int, raw_driver: *mut c_void, err: *mut FFI_AdbcError)
-> FFI_AdbcStatusCode;
}