| 1 | // Licensed to the Apache Software Foundation (ASF) under one |
| 2 | // or more contributor license agreements. See the NOTICE file |
| 3 | // distributed with this work for additional information |
| 4 | // regarding copyright ownership. The ASF licenses this file |
| 5 | // to you under the Apache License, Version 2.0 (the |
| 6 | // "License"); you may not use this file except in compliance |
| 7 | // with the License. You may obtain a copy of the License at |
| 8 | // |
| 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | // |
| 11 | // Unless required by applicable law or agreed to in writing, |
| 12 | // software distributed under the License is distributed on an |
| 13 | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | // KIND, either express or implied. See the License for the |
| 15 | // specific language governing permissions and limitations |
| 16 | // under the License. |
| 17 | |
| 18 | #pragma once |
| 19 | |
| 20 | #include "duckdb/common/adbc/adbc.h" |
| 21 | |
| 22 | #ifdef __cplusplus |
| 23 | extern "C" { |
| 24 | #endif |
| 25 | |
| 26 | #ifndef ADBC_DRIVER_MANAGER_H |
| 27 | #define ADBC_DRIVER_MANAGER_H |
| 28 | namespace duckdb_adbc { |
| 29 | /// \brief Common entry point for drivers via the driver manager. |
| 30 | /// |
| 31 | /// The driver manager can fill in default implementations of some |
| 32 | /// ADBC functions for drivers. Drivers must implement a minimum level |
| 33 | /// of functionality for this to be possible, however, and some |
| 34 | /// functions must be implemented by the driver. |
| 35 | /// |
| 36 | /// \param[in] driver_name An identifier for the driver (e.g. a path to a |
| 37 | /// shared library on Linux). |
| 38 | /// \param[in] entrypoint An identifier for the entrypoint (e.g. the |
| 39 | /// symbol to call for AdbcDriverInitFunc on Linux). |
| 40 | /// \param[in] version The ADBC revision to attempt to initialize. |
| 41 | /// \param[out] driver The table of function pointers to initialize. |
| 42 | /// \param[out] error An optional location to return an error message |
| 43 | /// if necessary. |
| 44 | ADBC_EXPORT |
| 45 | AdbcStatusCode AdbcLoadDriver(const char *driver_name, const char *entrypoint, int version, void *driver, |
| 46 | struct AdbcError *error); |
| 47 | |
| 48 | /// \brief Common entry point for drivers via the driver manager. |
| 49 | /// |
| 50 | /// The driver manager can fill in default implementations of some |
| 51 | /// ADBC functions for drivers. Drivers must implement a minimum level |
| 52 | /// of functionality for this to be possible, however, and some |
| 53 | /// functions must be implemented by the driver. |
| 54 | /// |
| 55 | /// \param[in] init_func The entrypoint to call. |
| 56 | /// \param[in] version The ADBC revision to attempt to initialize. |
| 57 | /// \param[out] driver The table of function pointers to initialize. |
| 58 | /// \param[out] error An optional location to return an error message |
| 59 | /// if necessary. |
| 60 | ADBC_EXPORT |
| 61 | AdbcStatusCode AdbcLoadDriverFromInitFunc(AdbcDriverInitFunc init_func, int version, void *driver, |
| 62 | struct AdbcError *error); |
| 63 | |
| 64 | /// \brief Set the AdbcDriverInitFunc to use. |
| 65 | /// |
| 66 | /// This is an extension to the ADBC API. The driver manager shims |
| 67 | /// the AdbcDatabase* functions to allow you to specify the |
| 68 | /// driver/entrypoint dynamically. This function lets you set the |
| 69 | /// entrypoint explicitly, for applications that can dynamically |
| 70 | /// load drivers on their own. |
| 71 | ADBC_EXPORT |
| 72 | AdbcStatusCode AdbcDriverManagerDatabaseSetInitFunc(struct AdbcDatabase *database, AdbcDriverInitFunc init_func, |
| 73 | struct AdbcError *error); |
| 74 | |
| 75 | /// \brief Get a human-friendly description of a status code. |
| 76 | ADBC_EXPORT |
| 77 | const char *AdbcStatusCodeMessage(AdbcStatusCode code); |
| 78 | |
| 79 | #endif // ADBC_DRIVER_MANAGER_H |
| 80 | |
| 81 | #ifdef __cplusplus |
| 82 | } |
| 83 | #endif |
| 84 | } // namespace duckdb_adbc |
| 85 | |