forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GDALSetAdbcDriverInitFunc() and use it in OGR ADBC driver
- Loading branch information
Showing
6 changed files
with
145 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/****************************************************************************** | ||
* Name: gdal_adbc.h | ||
* Project: GDAL Core | ||
* Purpose: GDAL Core ADBC related declarations. | ||
* Author: Even Rouault <even dot rouault at spatialys.com> | ||
* | ||
****************************************************************************** | ||
* Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
****************************************************************************/ | ||
|
||
#include "cpl_port.h" | ||
|
||
// Very minimal extract of adbc.h | ||
#define ADBC | ||
|
||
CPL_C_START | ||
|
||
typedef uint8_t AdbcStatusCode; | ||
struct AdbcError; | ||
typedef AdbcStatusCode (*AdbcDriverInitFunc)(int version, void *driver, | ||
struct AdbcError *error); | ||
|
||
CPL_C_END | ||
|
||
#include "gdal_adbc.h" | ||
|
||
//! Thread local ADBC driver initialization function | ||
static thread_local AdbcDriverInitFunc tlAdbcDriverInitFunc = nullptr; | ||
|
||
/************************************************************************/ | ||
/* GDALSetAdbcDriverInitFunc() */ | ||
/************************************************************************/ | ||
|
||
/** Sets the ADBC driver initialization function that should be used during | ||
* the next calls to the OGR ADBC driver. | ||
* | ||
* This is a thread-local setting. | ||
* | ||
* When set, it is honored by the OGR ADBC driver to pass the specified | ||
* initialization function as the argument of | ||
* AdbcDriverManagerDatabaseSetInitFunc() | ||
* | ||
* Setting it to NULL resets to the the default behaviour of the ADBC driver, | ||
* which is to honor the ADBC_DRIVER open option. | ||
*/ | ||
void GDALSetAdbcDriverInitFunc(AdbcDriverInitFunc init_func) | ||
{ | ||
tlAdbcDriverInitFunc = init_func; | ||
} | ||
|
||
/************************************************************************/ | ||
/* GDALGetAdbcDriverInitFunc() */ | ||
/************************************************************************/ | ||
|
||
/** Gets the ADBC driver initialization function for the current thread. | ||
*/ | ||
AdbcDriverInitFunc GDALGetAdbcDriverInitFunc() | ||
{ | ||
return tlAdbcDriverInitFunc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/****************************************************************************** | ||
* Name: gdal_adbc.h | ||
* Project: GDAL Core | ||
* Purpose: GDAL Core ADBC related declarations. | ||
* Author: Even Rouault <even dot rouault at spatialys.com> | ||
* | ||
****************************************************************************** | ||
* Copyright (c) 2024, Even Rouault <even dot rouault at spatialys.com> | ||
* | ||
* SPDX-License-Identifier: MIT | ||
****************************************************************************/ | ||
|
||
#ifndef GDAL_ADBC_H_INCLUDED | ||
#define GDAL_ADBC_H_INCLUDED | ||
|
||
/** | ||
* \file gdal_adbc.h | ||
* | ||
* C GDAL entry points for Arrow Database Connectivity (ADBC) | ||
* | ||
* This header can only be used if the ADBC macro is defined, indicating that | ||
* the abdc.h header has already been included before. | ||
* | ||
* \since GDAL 3.11 | ||
*/ | ||
|
||
#include "cpl_port.h" | ||
|
||
#ifdef ADBC | ||
|
||
CPL_C_START | ||
|
||
void CPL_DLL GDALSetAdbcDriverInitFunc(AdbcDriverInitFunc init_func); | ||
|
||
AdbcDriverInitFunc CPL_DLL GDALGetAdbcDriverInitFunc(void); | ||
|
||
CPL_C_END | ||
|
||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters