22
33#include " duckdb.hpp"
44
5- #ifndef DUCKDB_CPP_EXTENSION_ENTRY
6- #include " duckdb/main/extension_util.hpp"
7- #endif
8-
95#include " duckdb/parser/expression/constant_expression.hpp"
106#include " duckdb/parser/expression/function_expression.hpp"
117#include " duckdb/parser/tableref/table_function_ref.hpp"
@@ -51,11 +47,7 @@ unique_ptr<TableRef> ReadSheetReplacement(ClientContext &context, ReplacementSca
5147 return std::move (table_function);
5248}
5349
54- #ifdef DUCKDB_CPP_EXTENSION_ENTRY
5550static void LoadInternal (ExtensionLoader &loader) {
56- #else
57- static void LoadInternal (DatabaseInstance &db) {
58- #endif
5951 // Initialize OpenSSL
6052 SSL_library_init ();
6153 SSL_load_error_strings ();
@@ -70,30 +62,17 @@ static void LoadInternal(DatabaseInstance &db) {
7062
7163 GSheetCopyFunction gsheet_copy_function;
7264
73- #ifdef DUCKDB_CPP_EXTENSION_ENTRY
7465 loader.RegisterFunction (read_gsheet_function);
7566 loader.RegisterFunction (gsheet_copy_function);
7667 CreateGsheetSecretFunctions::Register (loader);
7768 auto &config = DBConfig::GetConfig (loader.GetDatabaseInstance ());
78- #else
79- ExtensionUtil::RegisterFunction (db, read_gsheet_function);
80- ExtensionUtil::RegisterFunction (db, gsheet_copy_function);
81- CreateGsheetSecretFunctions::Register (db);
82- auto &config = DBConfig::GetConfig (db);
83- #endif
8469
8570 config.replacement_scans .emplace_back (ReadSheetReplacement);
8671}
8772
88- #ifdef DUCKDB_CPP_EXTENSION_ENTRY
8973void GsheetsExtension::Load (ExtensionLoader &loader) {
9074 LoadInternal (loader);
9175}
92- #else
93- void GsheetsExtension::Load (DuckDB &db) {
94- LoadInternal (*db.instance );
95- }
96- #endif
9776
9877std::string GsheetsExtension::Name () {
9978 return " gsheets" ;
@@ -111,20 +90,9 @@ std::string GsheetsExtension::Version() const {
11190
11291extern " C" {
11392
114- #ifdef DUCKDB_CPP_EXTENSION_ENTRY
11593DUCKDB_CPP_EXTENSION_ENTRY (gsheets, loader) {
11694 duckdb::LoadInternal (loader);
11795}
118- #else
119- DUCKDB_EXTENSION_API void gsheets_init (duckdb::DatabaseInstance &db) {
120- duckdb::DuckDB db_wrapper (db);
121- db_wrapper.LoadExtension <duckdb::GsheetsExtension>();
122- }
123-
124- DUCKDB_EXTENSION_API const char *gsheets_version () {
125- return duckdb::DuckDB::LibraryVersion ();
126- }
127- #endif
12896}
12997
13098#ifndef DUCKDB_EXTENSION_MAIN
0 commit comments