ADBC
Arrow Database Connectivity
Loading...
Searching...
No Matches
base_driver.h
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 <charconv>
21#include <cstring>
22#include <memory>
23#include <optional>
24#include <string>
25#include <string_view>
26#include <type_traits>
27#include <utility>
28#include <variant>
29#include <vector>
30
31#include <arrow-adbc/adbc.h>
32
34
47namespace adbc::driver {
48
50enum class LifecycleState {
52 kUninitialized,
54 kInitialized,
55};
56
59class Option {
60 public:
62 struct Unset {};
64 using Value = std::variant<Unset, std::string, std::vector<uint8_t>, int64_t, double>;
65
66 Option() : value_(Unset{}) {}
69 explicit Option(const char* value)
70 : value_(value ? Value(std::string(value)) : Value{Unset{}}) {}
71 explicit Option(std::string value) : value_(std::move(value)) {}
72 explicit Option(std::vector<uint8_t> value) : value_(std::move(value)) {}
73 explicit Option(double value) : value_(value) {}
74 explicit Option(int64_t value) : value_(value) {}
75
76 const Value& value() const& { return value_; }
77 Value& value() && { return value_; }
78
80 bool has_value() const { return !std::holds_alternative<Unset>(value_); }
81
84 return std::visit(
85 [&](auto&& value) -> Result<bool> {
86 using T = std::decay_t<decltype(value)>;
87 if constexpr (std::is_same_v<T, std::string>) {
88 if (value == ADBC_OPTION_VALUE_ENABLED) {
89 return true;
90 } else if (value == ADBC_OPTION_VALUE_DISABLED) {
91 return false;
92 }
93 }
94 return status::InvalidArgument("Invalid boolean value ", this->Format());
95 },
96 value_);
97 }
98
101 return std::visit(
102 [&](auto&& value) -> Result<int64_t> {
103 using T = std::decay_t<decltype(value)>;
104 if constexpr (std::is_same_v<T, int64_t>) {
105 return value;
106 } else if constexpr (std::is_same_v<T, std::string>) {
107 int64_t parsed = 0;
108 auto begin = value.data();
109 auto end = value.data() + value.size();
110 auto result = std::from_chars(begin, end, parsed);
111 if (result.ec != std::errc()) {
112 return status::InvalidArgument("Invalid integer value '", value,
113 "': not an integer", value);
114 } else if (result.ptr != end) {
115 return status::InvalidArgument("Invalid integer value '", value,
116 "': trailing data", value);
117 }
118 return parsed;
119 } else {
120 return status::InvalidArgument("Invalid integer value ", this->Format());
121 }
122 },
123 value_);
124 }
125
128 return std::visit(
129 [&](auto&& value) -> Result<std::string_view> {
130 using T = std::decay_t<decltype(value)>;
131 if constexpr (std::is_same_v<T, std::string>) {
132 return value;
133 } else {
134 return status::InvalidArgument("Invalid string value ", this->Format());
135 }
136 },
137 value_);
138 }
139
141 std::string Format() const {
142 return std::visit(
143 [&](auto&& value) -> std::string {
144 using T = std::decay_t<decltype(value)>;
145 if constexpr (std::is_same_v<T, adbc::driver::Option::Unset>) {
146 return "(NULL)";
147 } else if constexpr (std::is_same_v<T, std::string>) {
148 return std::string("'") + value + "'";
149 } else if constexpr (std::is_same_v<T, std::vector<uint8_t>>) {
150 return std::string("(") + std::to_string(value.size()) + " bytes)";
151 } else {
152 return std::to_string(value);
153 }
154 },
155 value_);
156 }
157
158 private:
159 Value value_;
160
161 // Methods used by trampolines to export option values in C below
162 friend class ObjectBase;
163 AdbcStatusCode CGet(char* out, size_t* length, AdbcError* error) const {
164 {
165 if (!length || (!out && *length > 0)) {
166 return status::InvalidArgument("Must provide both out and length to GetOption")
167 .ToAdbc(error);
168 }
169 return std::visit(
170 [&](auto&& value) -> AdbcStatusCode {
171 using T = std::decay_t<decltype(value)>;
172 if constexpr (std::is_same_v<T, std::string>) {
173 size_t value_size_with_terminator = value.size() + 1;
174 if (*length >= value_size_with_terminator) {
175 std::memcpy(out, value.data(), value.size());
176 out[value.size()] = 0;
177 }
178 *length = value_size_with_terminator;
179 return ADBC_STATUS_OK;
180 } else if constexpr (std::is_same_v<T, Unset>) {
181 return status::NotFound("Unknown option").ToAdbc(error);
182 } else {
183 return status::NotFound("Option value is not a string").ToAdbc(error);
184 }
185 },
186 value_);
187 }
188 }
189 AdbcStatusCode CGet(uint8_t* out, size_t* length, AdbcError* error) const {
190 if (!length || (!out && *length > 0)) {
191 return status::InvalidArgument("Must provide both out and length to GetOption")
192 .ToAdbc(error);
193 }
194 return std::visit(
195 [&](auto&& value) -> AdbcStatusCode {
196 using T = std::decay_t<decltype(value)>;
197 if constexpr (std::is_same_v<T, std::string> ||
198 std::is_same_v<T, std::vector<uint8_t>>) {
199 if (*length >= value.size()) {
200 std::memcpy(out, value.data(), value.size());
201 }
202 *length = value.size();
203 return ADBC_STATUS_OK;
204 } else if constexpr (std::is_same_v<T, Unset>) {
205 return status::NotFound("Unknown option").ToAdbc(error);
206 } else {
207 return status::NotFound("Option value is not a bytestring").ToAdbc(error);
208 }
209 },
210 value_);
211 }
212 AdbcStatusCode CGet(int64_t* out, AdbcError* error) const {
213 {
214 if (!out) {
215 return status::InvalidArgument("Must provide out to GetOption").ToAdbc(error);
216 }
217 return std::visit(
218 [&](auto&& value) -> AdbcStatusCode {
219 using T = std::decay_t<decltype(value)>;
220 if constexpr (std::is_same_v<T, int64_t>) {
221 *out = value;
222 return ADBC_STATUS_OK;
223 } else if constexpr (std::is_same_v<T, Unset>) {
224 return status::NotFound("Unknown option").ToAdbc(error);
225 } else {
226 return status::NotFound("Option value is not an integer").ToAdbc(error);
227 }
228 },
229 value_);
230 }
231 }
232 AdbcStatusCode CGet(double* out, AdbcError* error) const {
233 if (!out) {
234 return status::InvalidArgument("Must provide out to GetOption").ToAdbc(error);
235 }
236 return std::visit(
237 [&](auto&& value) -> AdbcStatusCode {
238 using T = std::decay_t<decltype(value)>;
239 if constexpr (std::is_same_v<T, double> || std::is_same_v<T, int64_t>) {
240 *out = static_cast<double>(value);
241 return ADBC_STATUS_OK;
242 } else if constexpr (std::is_same_v<T, Unset>) {
243 return status::NotFound("Unknown option").ToAdbc(error);
244 } else {
245 return status::NotFound("Option value is not a double").ToAdbc(error);
246 }
247 },
248 value_);
249 }
250};
251
257 public:
258 ObjectBase() = default;
259 virtual ~ObjectBase() = default;
260
261 // Called After zero or more SetOption() calls. The parent is the
262 // private_data of the AdbcDatabase, or AdbcConnection when initializing a
263 // subclass of ConnectionObjectBase, and StatementObjectBase (respectively),
264 // or otherwise nullptr. For example, if you have defined
265 // Driver<MyDatabase, MyConnection, MyStatement>, you can
266 // reinterpret_cast<MyDatabase>(parent) in MyConnection::Init().
267
276 virtual AdbcStatusCode Init(void* parent, AdbcError* error) {
277 lifecycle_state_ = LifecycleState::kInitialized;
278 return ADBC_STATUS_OK;
279 }
280
291 virtual AdbcStatusCode Release(AdbcError* error) { return ADBC_STATUS_OK; }
292
294 virtual Result<Option> GetOption(std::string_view key) {
295 Option option(nullptr);
296 return option;
297 }
298
300 virtual AdbcStatusCode SetOption(std::string_view key, Option value, AdbcError* error) {
302 }
303
304 protected:
305 LifecycleState lifecycle_state_;
306
307 private:
308 // Let the Driver use these to expose C callables wrapping option setters/getters
309 template <typename DatabaseT, typename ConnectionT, typename StatementT>
310 friend class Driver;
311
312 template <typename T>
313 AdbcStatusCode CSetOption(const char* key, T value, AdbcError* error) {
314 Option option(value);
315 return SetOption(key, std::move(option), error);
316 }
317
318 AdbcStatusCode CSetOptionBytes(const char* key, const uint8_t* value, size_t length,
319 AdbcError* error) {
320 std::vector<uint8_t> cppvalue(value, value + length);
321 Option option(std::move(cppvalue));
322 return SetOption(key, std::move(option), error);
323 }
324
325 template <typename T>
326 AdbcStatusCode CGetOptionStringLike(const char* key, T* value, size_t* length,
327 AdbcError* error) {
328 RAISE_RESULT(error, auto option, GetOption(key));
329 return option.CGet(value, length, error);
330 }
331
332 template <typename T>
333 AdbcStatusCode CGetOptionNumeric(const char* key, T* value, AdbcError* error) {
334 RAISE_RESULT(error, auto option, GetOption(key));
335 return option.CGet(value, error);
336 }
337};
338
340template <typename DatabaseT, typename ConnectionT, typename StatementT, typename T>
342
343template <typename DatabaseT, typename ConnectionT, typename StatementT>
344struct ResolveObjectTImpl<DatabaseT, ConnectionT, StatementT, struct AdbcDatabase> {
345 using type = DatabaseT;
346};
347template <typename DatabaseT, typename ConnectionT, typename StatementT>
348struct ResolveObjectTImpl<DatabaseT, ConnectionT, StatementT, struct AdbcConnection> {
349 using type = ConnectionT;
350};
351template <typename DatabaseT, typename ConnectionT, typename StatementT>
352struct ResolveObjectTImpl<DatabaseT, ConnectionT, StatementT, struct AdbcStatement> {
353 using type = StatementT;
354};
355
357template <typename DatabaseT, typename ConnectionT, typename StatementT, typename T>
358using ResolveObjectT =
360
361// Driver authors can declare a template specialization of the Driver class
362// and use it to provide their driver init function. It is possible, but
363// rarely useful, to subclass a driver.
364template <typename DatabaseT, typename ConnectionT, typename StatementT>
365class Driver {
366 public:
367 static AdbcStatusCode Init(int version, void* raw_driver, AdbcError* error) {
368 if (version != ADBC_VERSION_1_0_0 && version != ADBC_VERSION_1_1_0) {
370 }
371
372 auto* driver = reinterpret_cast<AdbcDriver*>(raw_driver);
373 if (version >= ADBC_VERSION_1_1_0) {
374 std::memset(driver, 0, ADBC_DRIVER_1_1_0_SIZE);
375
376 driver->ErrorGetDetailCount = &CErrorGetDetailCount;
377 driver->ErrorGetDetail = &CErrorGetDetail;
378
379 driver->DatabaseGetOption = &CGetOption<AdbcDatabase>;
380 driver->DatabaseGetOptionBytes = &CGetOptionBytes<AdbcDatabase>;
381 driver->DatabaseGetOptionInt = &CGetOptionInt<AdbcDatabase>;
382 driver->DatabaseGetOptionDouble = &CGetOptionDouble<AdbcDatabase>;
383 driver->DatabaseSetOptionBytes = &CSetOptionBytes<AdbcDatabase>;
384 driver->DatabaseSetOptionInt = &CSetOptionInt<AdbcDatabase>;
385 driver->DatabaseSetOptionDouble = &CSetOptionDouble<AdbcDatabase>;
386
387 driver->ConnectionCancel = &CConnectionCancel;
388 driver->ConnectionGetOption = &CGetOption<AdbcConnection>;
389 driver->ConnectionGetOptionBytes = &CGetOptionBytes<AdbcConnection>;
390 driver->ConnectionGetOptionInt = &CGetOptionInt<AdbcConnection>;
391 driver->ConnectionGetOptionDouble = &CGetOptionDouble<AdbcConnection>;
392 driver->ConnectionGetStatistics = &CConnectionGetStatistics;
393 driver->ConnectionGetStatisticNames = &CConnectionGetStatisticNames;
394 driver->ConnectionSetOptionBytes = &CSetOptionBytes<AdbcConnection>;
395 driver->ConnectionSetOptionInt = &CSetOptionInt<AdbcConnection>;
396 driver->ConnectionSetOptionDouble = &CSetOptionDouble<AdbcConnection>;
397
398 driver->StatementCancel = &CStatementCancel;
399 driver->StatementExecuteSchema = &CStatementExecuteSchema;
400 driver->StatementGetOption = &CGetOption<AdbcStatement>;
401 driver->StatementGetOptionBytes = &CGetOptionBytes<AdbcStatement>;
402 driver->StatementGetOptionInt = &CGetOptionInt<AdbcStatement>;
403 driver->StatementGetOptionDouble = &CGetOptionDouble<AdbcStatement>;
404 driver->StatementSetOptionBytes = &CSetOptionBytes<AdbcStatement>;
405 driver->StatementSetOptionInt = &CSetOptionInt<AdbcStatement>;
406 driver->StatementSetOptionDouble = &CSetOptionDouble<AdbcStatement>;
407 } else {
408 std::memset(driver, 0, ADBC_DRIVER_1_0_0_SIZE);
409 }
410
411 driver->private_data = new Driver();
412 driver->release = &CDriverRelease;
413
414 driver->DatabaseInit = &CDatabaseInit;
415 driver->DatabaseNew = &CNew<AdbcDatabase>;
416 driver->DatabaseRelease = &CRelease<AdbcDatabase>;
417 driver->DatabaseSetOption = &CSetOption<AdbcDatabase>;
418
419 driver->ConnectionCommit = &CConnectionCommit;
420 driver->ConnectionGetInfo = &CConnectionGetInfo;
421 driver->ConnectionGetObjects = &CConnectionGetObjects;
422 driver->ConnectionGetTableSchema = &CConnectionGetTableSchema;
423 driver->ConnectionGetTableTypes = &CConnectionGetTableTypes;
424 driver->ConnectionInit = &CConnectionInit;
425 driver->ConnectionNew = &CNew<AdbcConnection>;
426 driver->ConnectionRelease = &CRelease<AdbcConnection>;
427 driver->ConnectionReadPartition = &CConnectionReadPartition;
428 driver->ConnectionRollback = &CConnectionRollback;
429 driver->ConnectionSetOption = &CSetOption<AdbcConnection>;
430
431 driver->StatementBind = &CStatementBind;
432 driver->StatementBindStream = &CStatementBindStream;
433 driver->StatementExecutePartitions = &CStatementExecutePartitions;
434 driver->StatementExecuteQuery = &CStatementExecuteQuery;
435 driver->StatementGetParameterSchema = &CStatementGetParameterSchema;
436 driver->StatementNew = &CStatementNew;
437 driver->StatementPrepare = &CStatementPrepare;
438 driver->StatementRelease = &CRelease<AdbcStatement>;
439 driver->StatementSetOption = &CSetOption<AdbcStatement>;
440 driver->StatementSetSqlQuery = &CStatementSetSqlQuery;
441 driver->StatementSetSubstraitPlan = &CStatementSetSubstraitPlan;
442
443 return ADBC_STATUS_OK;
444 }
445
446 // Driver trampolines
447 static AdbcStatusCode CDriverRelease(AdbcDriver* driver, AdbcError* error) {
448 auto driver_private = reinterpret_cast<Driver*>(driver->private_data);
449 delete driver_private;
450 driver->private_data = nullptr;
451 return ADBC_STATUS_OK;
452 }
453
454 static int CErrorGetDetailCount(const AdbcError* error) {
456 return 0;
457 }
458
459 auto error_obj = reinterpret_cast<Status*>(error->private_data);
460 if (!error_obj) {
461 return 0;
462 }
463 return error_obj->CDetailCount();
464 }
465
466 static AdbcErrorDetail CErrorGetDetail(const AdbcError* error, int index) {
468 return {nullptr, nullptr, 0};
469 }
470
471 auto error_obj = reinterpret_cast<Status*>(error->private_data);
472 if (!error_obj) {
473 return {nullptr, nullptr, 0};
474 }
475
476 return error_obj->CDetail(index);
477 }
478
479 // Templatable trampolines
480
481 template <typename T>
482 static AdbcStatusCode CNew(T* obj, AdbcError* error) {
483 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
484 auto private_data = new ObjectT();
485 obj->private_data = private_data;
486 return ADBC_STATUS_OK;
487 }
488
489 template <typename T>
490 static AdbcStatusCode CRelease(T* obj, AdbcError* error) {
491 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
492 if (obj == nullptr) return ADBC_STATUS_INVALID_STATE;
493 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
494 if (private_data == nullptr) return ADBC_STATUS_INVALID_STATE;
495 AdbcStatusCode result = private_data->Release(error);
496 if (result != ADBC_STATUS_OK) {
497 return result;
498 }
499
500 delete private_data;
501 obj->private_data = nullptr;
502 return ADBC_STATUS_OK;
503 }
504
505 template <typename T>
506 static AdbcStatusCode CSetOption(T* obj, const char* key, const char* value,
507 AdbcError* error) {
508 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
509 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
510 return private_data->template CSetOption<>(key, value, error);
511 }
512
513 template <typename T>
514 static AdbcStatusCode CSetOptionBytes(T* obj, const char* key, const uint8_t* value,
515 size_t length, AdbcError* error) {
516 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
517 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
518 return private_data->CSetOptionBytes(key, value, length, error);
519 }
520
521 template <typename T>
522 static AdbcStatusCode CSetOptionInt(T* obj, const char* key, int64_t value,
523 AdbcError* error) {
524 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
525 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
526 return private_data->template CSetOption<>(key, value, error);
527 }
528
529 template <typename T>
530 static AdbcStatusCode CSetOptionDouble(T* obj, const char* key, double value,
531 AdbcError* error) {
532 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
533 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
534 return private_data->template CSetOption<>(key, value, error);
535 }
536
537 template <typename T>
538 static AdbcStatusCode CGetOption(T* obj, const char* key, char* value, size_t* length,
539 AdbcError* error) {
540 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
541 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
542 return private_data->template CGetOptionStringLike<>(key, value, length, error);
543 }
544
545 template <typename T>
546 static AdbcStatusCode CGetOptionBytes(T* obj, const char* key, uint8_t* value,
547 size_t* length, AdbcError* error) {
548 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
549 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
550 return private_data->template CGetOptionStringLike<>(key, value, length, error);
551 }
552
553 template <typename T>
554 static AdbcStatusCode CGetOptionInt(T* obj, const char* key, int64_t* value,
555 AdbcError* error) {
556 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
557 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
558 return private_data->template CGetOptionNumeric<>(key, value, error);
559 }
560
561 template <typename T>
562 static AdbcStatusCode CGetOptionDouble(T* obj, const char* key, double* value,
563 AdbcError* error) {
564 using ObjectT = ResolveObjectT<DatabaseT, ConnectionT, StatementT, T>;
565 auto private_data = reinterpret_cast<ObjectT*>(obj->private_data);
566 return private_data->template CGetOptionNumeric<>(key, value, error);
567 }
568
569#define CHECK_INIT(DATABASE, ERROR) \
570 if (!(DATABASE) || !(DATABASE)->private_data) { \
571 return status::InvalidState("Database is uninitialized").ToAdbc(ERROR); \
572 }
573
574 // Database trampolines
575 static AdbcStatusCode CDatabaseInit(AdbcDatabase* database, AdbcError* error) {
576 CHECK_INIT(database, error);
577 auto private_data = reinterpret_cast<DatabaseT*>(database->private_data);
578 return private_data->Init(nullptr, error);
579 }
580
581#undef CHECK_INIT
582#define CHECK_INIT(CONNECTION, ERROR) \
583 if (!(CONNECTION) || !(CONNECTION)->private_data) { \
584 return status::InvalidState("Connection is uninitialized").ToAdbc(ERROR); \
585 }
586
587 // Connection trampolines
588 static AdbcStatusCode CConnectionInit(AdbcConnection* connection,
589 AdbcDatabase* database, AdbcError* error) {
590 CHECK_INIT(connection, error);
591 if (!database || !database->private_data) {
592 return status::InvalidState("Database is uninitialized").ToAdbc(error);
593 }
594 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
595 return private_data->Init(database->private_data, error);
596 }
597
598 static AdbcStatusCode CConnectionCancel(AdbcConnection* connection, AdbcError* error) {
599 CHECK_INIT(connection, error);
600 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
601 return private_data->Cancel(error);
602 }
603
604 static AdbcStatusCode CConnectionGetInfo(AdbcConnection* connection,
605 const uint32_t* info_codes,
606 size_t info_codes_length,
607 ArrowArrayStream* out, AdbcError* error) {
608 CHECK_INIT(connection, error);
609 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
610 return private_data->GetInfo(info_codes, info_codes_length, out, error);
611 }
612
613 static AdbcStatusCode CConnectionGetObjects(AdbcConnection* connection, int depth,
614 const char* catalog, const char* db_schema,
615 const char* table_name,
616 const char** table_type,
617 const char* column_name,
618 ArrowArrayStream* out, AdbcError* error) {
619 CHECK_INIT(connection, error);
620 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
621 return private_data->GetObjects(depth, catalog, db_schema, table_name, table_type,
622 column_name, out, error);
623 }
624
625 static AdbcStatusCode CConnectionGetStatistics(
626 AdbcConnection* connection, const char* catalog, const char* db_schema,
627 const char* table_name, char approximate, ArrowArrayStream* out, AdbcError* error) {
628 CHECK_INIT(connection, error);
629 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
630 return private_data->GetStatistics(catalog, db_schema, table_name, approximate, out,
631 error);
632 }
633
634 static AdbcStatusCode CConnectionGetStatisticNames(AdbcConnection* connection,
635 ArrowArrayStream* out,
636 AdbcError* error) {
637 CHECK_INIT(connection, error);
638 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
639 return private_data->GetStatisticNames(out, error);
640 }
641
642 static AdbcStatusCode CConnectionGetTableSchema(AdbcConnection* connection,
643 const char* catalog,
644 const char* db_schema,
645 const char* table_name,
646 ArrowSchema* schema, AdbcError* error) {
647 CHECK_INIT(connection, error);
648 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
649 return private_data->GetTableSchema(catalog, db_schema, table_name, schema, error);
650 }
651
652 static AdbcStatusCode CConnectionGetTableTypes(AdbcConnection* connection,
653 ArrowArrayStream* out,
654 AdbcError* error) {
655 CHECK_INIT(connection, error);
656 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
657 return private_data->GetTableTypes(out, error);
658 }
659
660 static AdbcStatusCode CConnectionReadPartition(AdbcConnection* connection,
661 const uint8_t* serialized_partition,
662 size_t serialized_length,
663 ArrowArrayStream* out,
664 AdbcError* error) {
665 CHECK_INIT(connection, error);
666 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
667 return private_data->ReadPartition(serialized_partition, serialized_length, out,
668 error);
669 }
670
671 static AdbcStatusCode CConnectionCommit(AdbcConnection* connection, AdbcError* error) {
672 CHECK_INIT(connection, error);
673 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
674 return private_data->Commit(error);
675 }
676
677 static AdbcStatusCode CConnectionRollback(AdbcConnection* connection,
678 AdbcError* error) {
679 CHECK_INIT(connection, error);
680 auto private_data = reinterpret_cast<ConnectionT*>(connection->private_data);
681 return private_data->Rollback(error);
682 }
683
684#undef CHECK_INIT
685#define CHECK_INIT(STATEMENT, ERROR) \
686 if (!(STATEMENT) || !(STATEMENT)->private_data) { \
687 return status::InvalidState("Statement is uninitialized").ToAdbc(ERROR); \
688 }
689
690 // Statement trampolines
691 static AdbcStatusCode CStatementNew(AdbcConnection* connection,
692 AdbcStatement* statement, AdbcError* error) {
693 if (!connection || !connection->private_data) {
694 return status::InvalidState("Connection is uninitialized").ToAdbc(error);
695 }
696 auto private_data = new StatementT();
697 AdbcStatusCode status = private_data->Init(connection->private_data, error);
698 if (status != ADBC_STATUS_OK) {
699 delete private_data;
700 }
701
702 statement->private_data = private_data;
703 return ADBC_STATUS_OK;
704 }
705
706 static AdbcStatusCode CStatementBind(AdbcStatement* statement, ArrowArray* values,
707 ArrowSchema* schema, AdbcError* error) {
708 CHECK_INIT(statement, error);
709 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
710 return private_data->Bind(values, schema, error);
711 }
712
713 static AdbcStatusCode CStatementBindStream(AdbcStatement* statement,
714 ArrowArrayStream* stream, AdbcError* error) {
715 CHECK_INIT(statement, error);
716 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
717 return private_data->BindStream(stream, error);
718 }
719
720 static AdbcStatusCode CStatementCancel(AdbcStatement* statement, AdbcError* error) {
721 CHECK_INIT(statement, error);
722 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
723 return private_data->Cancel(error);
724 }
725
726 static AdbcStatusCode CStatementExecutePartitions(AdbcStatement* statement,
727 struct ArrowSchema* schema,
728 struct AdbcPartitions* partitions,
729 int64_t* rows_affected,
730 AdbcError* error) {
731 CHECK_INIT(statement, error);
732 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
733 return private_data->ExecutePartitions(schema, partitions, rows_affected, error);
734 }
735
736 static AdbcStatusCode CStatementExecuteQuery(AdbcStatement* statement,
737 ArrowArrayStream* stream,
738 int64_t* rows_affected, AdbcError* error) {
739 CHECK_INIT(statement, error);
740 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
741 return private_data->ExecuteQuery(stream, rows_affected, error);
742 }
743
744 static AdbcStatusCode CStatementExecuteSchema(AdbcStatement* statement,
745 ArrowSchema* schema, AdbcError* error) {
746 CHECK_INIT(statement, error);
747 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
748 return private_data->ExecuteSchema(schema, error);
749 }
750
751 static AdbcStatusCode CStatementGetParameterSchema(AdbcStatement* statement,
752 ArrowSchema* schema,
753 AdbcError* error) {
754 CHECK_INIT(statement, error);
755 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
756 return private_data->GetParameterSchema(schema, error);
757 }
758
759 static AdbcStatusCode CStatementPrepare(AdbcStatement* statement, AdbcError* error) {
760 CHECK_INIT(statement, error);
761 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
762 return private_data->Prepare(error);
763 }
764
765 static AdbcStatusCode CStatementSetSqlQuery(AdbcStatement* statement, const char* query,
766 AdbcError* error) {
767 CHECK_INIT(statement, error);
768 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
769 return private_data->SetSqlQuery(query, error);
770 }
771
772 static AdbcStatusCode CStatementSetSubstraitPlan(AdbcStatement* statement,
773 const uint8_t* plan, size_t length,
774 AdbcError* error) {
775 CHECK_INIT(statement, error);
776 auto private_data = reinterpret_cast<StatementT*>(statement->private_data);
777 return private_data->SetSubstraitPlan(plan, length, error);
778 }
779
780#undef CHECK_INIT
781};
782
783template <typename Derived>
784class BaseDatabase : public ObjectBase {
785 public:
787
788 BaseDatabase() : ObjectBase() {}
789 ~BaseDatabase() = default;
790
792 AdbcStatusCode Init(void* parent, AdbcError* error) override {
793 RAISE_STATUS(error, impl().InitImpl());
794 return ObjectBase::Init(parent, error);
795 }
796
799 RAISE_STATUS(error, impl().ReleaseImpl());
800 return ADBC_STATUS_OK;
801 }
802
804 AdbcStatusCode SetOption(std::string_view key, Option value,
805 AdbcError* error) override {
806 RAISE_STATUS(error, impl().SetOptionImpl(key, std::move(value)));
807 return ADBC_STATUS_OK;
808 }
809
811 virtual Status InitImpl() { return status::Ok(); }
812
814 virtual Status ReleaseImpl() { return status::Ok(); }
815
817 virtual Status SetOptionImpl(std::string_view key, Option value) {
818 return status::NotImplemented(Derived::kErrorPrefix, " Unknown database option ", key,
819 "=", value.Format());
820 }
821
822 private:
823 Derived& impl() { return static_cast<Derived&>(*this); }
824};
825
826template <typename Derived>
828 public:
830
832 enum class AutocommitState {
833 kAutocommit,
834 kTransaction,
835 };
836
838 ~BaseConnection() = default;
839
841 AdbcStatusCode Init(void* parent, AdbcError* error) override {
842 RAISE_STATUS(error, impl().InitImpl(parent));
843 return ObjectBase::Init(parent, error);
844 }
845
847 virtual Status InitImpl(void* parent) { return status::Ok(); }
848
850 AdbcStatusCode Cancel(AdbcError* error) { return impl().CancelImpl().ToAdbc(error); }
851
852 Status CancelImpl() { return status::NotImplemented("Cancel"); }
853
855 AdbcStatusCode Commit(AdbcError* error) { return impl().CommitImpl().ToAdbc(error); }
856
857 Status CommitImpl() { return status::NotImplemented("Commit"); }
858
860 AdbcStatusCode GetInfo(const uint32_t* info_codes, size_t info_codes_length,
861 ArrowArrayStream* out, AdbcError* error) {
862 std::vector<uint32_t> codes(info_codes, info_codes + info_codes_length);
863 RAISE_STATUS(error, impl().GetInfoImpl(codes, out));
864 return ADBC_STATUS_OK;
865 }
866
867 Status GetInfoImpl(const std::vector<uint32_t> info_codes, ArrowArrayStream* out) {
868 return status::NotImplemented("GetInfo");
869 }
870
872 AdbcStatusCode GetObjects(int c_depth, const char* catalog, const char* db_schema,
873 const char* table_name, const char** table_type,
874 const char* column_name, ArrowArrayStream* out,
875 AdbcError* error) {
876 const auto catalog_filter =
877 catalog ? std::make_optional(std::string_view(catalog)) : std::nullopt;
878 const auto schema_filter =
879 db_schema ? std::make_optional(std::string_view(db_schema)) : std::nullopt;
880 const auto table_filter =
881 table_name ? std::make_optional(std::string_view(table_name)) : std::nullopt;
882 const auto column_filter =
883 column_name ? std::make_optional(std::string_view(column_name)) : std::nullopt;
884 std::vector<std::string_view> table_type_filter;
885 while (table_type && *table_type) {
886 if (*table_type) {
887 table_type_filter.push_back(std::string_view(*table_type));
888 }
889 table_type++;
890 }
891
893 error, impl().GetObjectsImpl(c_depth, catalog_filter, schema_filter, table_filter,
894 column_filter, table_type_filter, out));
895
896 return ADBC_STATUS_OK;
897 }
898
899 Status GetObjectsImpl(int c_depth, std::optional<std::string_view> catalog_filter,
900 std::optional<std::string_view> schema_filter,
901 std::optional<std::string_view> table_filter,
902 std::optional<std::string_view> column_filter,
903 const std::vector<std::string_view>& table_types,
904 struct ArrowArrayStream* out) {
905 return status::NotImplemented("GetObjects");
906 }
907
909 AdbcStatusCode GetStatistics(const char* catalog, const char* db_schema,
910 const char* table_name, char approximate,
911 ArrowArrayStream* out, AdbcError* error) {
912 const auto catalog_filter =
913 catalog ? std::make_optional(std::string_view(catalog)) : std::nullopt;
914 const auto schema_filter =
915 db_schema ? std::make_optional(std::string_view(db_schema)) : std::nullopt;
916 const auto table_filter =
917 table_name ? std::make_optional(std::string_view(table_name)) : std::nullopt;
918 RAISE_STATUS(error, impl().GetStatisticsImpl(catalog_filter, schema_filter,
919 table_filter, approximate != 0, out));
920 return ADBC_STATUS_OK;
921 }
922
923 Status GetStatisticsImpl(std::optional<std::string_view> catalog,
924 std::optional<std::string_view> db_schema,
925 std::optional<std::string_view> table_name, bool approximate,
926 ArrowArrayStream* out) {
927 return status::NotImplemented("GetStatistics");
928 }
929
931 AdbcStatusCode GetStatisticNames(ArrowArrayStream* out, AdbcError* error) {
932 RAISE_STATUS(error, impl().GetStatisticNames(out));
933 return ADBC_STATUS_OK;
934 }
935
936 Status GetStatisticNames(ArrowArrayStream* out) {
937 return status::NotImplemented("GetStatisticNames");
938 }
939
941 AdbcStatusCode GetTableSchema(const char* catalog, const char* db_schema,
942 const char* table_name, ArrowSchema* schema,
943 AdbcError* error) {
944 if (!table_name) {
945 return status::InvalidArgument(Derived::kErrorPrefix,
946 " GetTableSchema: must provide table_name")
947 .ToAdbc(error);
948 }
949
950 std::optional<std::string_view> catalog_param =
951 catalog ? std::make_optional(std::string_view(catalog)) : std::nullopt;
952 std::optional<std::string_view> db_schema_param =
953 db_schema ? std::make_optional(std::string_view(db_schema)) : std::nullopt;
954
955 RAISE_STATUS(error, impl().GetTableSchemaImpl(catalog_param, db_schema_param,
956 table_name, schema));
957 return ADBC_STATUS_OK;
958 }
959
960 Status GetTableSchemaImpl(std::optional<std::string_view> catalog,
961 std::optional<std::string_view> db_schema,
962 std::string_view table_name, ArrowSchema* out) {
963 return status::NotImplemented("GetTableSchema");
964 }
965
967 AdbcStatusCode GetTableTypes(ArrowArrayStream* out, AdbcError* error) {
968 RAISE_STATUS(error, impl().GetTableTypesImpl(out));
969 return ADBC_STATUS_OK;
970 }
971
972 Status GetTableTypesImpl(ArrowArrayStream* out) {
973 return status::NotImplemented("GetTableTypes");
974 }
975
977 AdbcStatusCode ReadPartition(const uint8_t* serialized_partition,
978 size_t serialized_length, ArrowArrayStream* out,
979 AdbcError* error) {
980 std::string_view partition(reinterpret_cast<const char*>(serialized_partition),
981 serialized_length);
982 RAISE_STATUS(error, impl().ReadPartitionImpl(partition, out));
983 return ADBC_STATUS_OK;
984 }
985
986 Status ReadPartitionImpl(std::string_view serialized_partition, ArrowArrayStream* out) {
987 return status::NotImplemented("ReadPartition");
988 }
989
992 RAISE_STATUS(error, impl().ReleaseImpl());
993 return ADBC_STATUS_OK;
994 }
995
996 Status ReleaseImpl() { return status::Ok(); }
997
999 AdbcStatusCode Rollback(AdbcError* error) {
1000 RAISE_STATUS(error, impl().RollbackImpl());
1001 return ADBC_STATUS_OK;
1002 }
1003
1004 Status RollbackImpl() { return status::NotImplemented("Rollback"); }
1005
1007 AdbcStatusCode SetOption(std::string_view key, Option value,
1008 AdbcError* error) override {
1009 RAISE_STATUS(error, impl().SetOptionImpl(key, value));
1010 return ADBC_STATUS_OK;
1011 }
1012
1014 virtual Status SetOptionImpl(std::string_view key, Option value) {
1015 return status::NotImplemented(Derived::kErrorPrefix, " Unknown connection option ",
1016 key, "=", value.Format());
1017 }
1018
1019 private:
1020 Derived& impl() { return static_cast<Derived&>(*this); }
1021};
1022
1023template <typename Derived>
1025 public:
1027
1029 AdbcStatusCode Init(void* parent, AdbcError* error) override {
1030 RAISE_STATUS(error, impl().InitImpl(parent));
1031 return ObjectBase::Init(parent, error);
1032 }
1033
1035 Status InitImpl(void* parent) { return status::Ok(); }
1036
1039 RAISE_STATUS(error, impl().ReleaseImpl());
1040 return ADBC_STATUS_OK;
1041 }
1042
1043 Status ReleaseImpl() { return status::Ok(); }
1044
1046 AdbcStatusCode SetOption(std::string_view key, Option value,
1047 AdbcError* error) override {
1048 RAISE_STATUS(error, impl().SetOptionImpl(key, value));
1049 return ADBC_STATUS_OK;
1050 }
1051
1053 virtual Status SetOptionImpl(std::string_view key, Option value) {
1054 return status::NotImplemented(Derived::kErrorPrefix, " Unknown statement option ",
1055 key, "=", value.Format());
1056 }
1057
1058 AdbcStatusCode ExecuteQuery(ArrowArrayStream* stream, int64_t* rows_affected,
1059 AdbcError* error) {
1060 RAISE_RESULT(error, int64_t rows_affected_result, impl().ExecuteQueryImpl(stream));
1061 if (rows_affected) {
1062 *rows_affected = rows_affected_result;
1063 }
1064
1065 return ADBC_STATUS_OK;
1066 }
1067
1068 Result<int64_t> ExecuteQueryImpl(ArrowArrayStream* stream) {
1069 return status::NotImplemented("ExecuteQuery");
1070 }
1071
1072 AdbcStatusCode ExecuteSchema(ArrowSchema* schema, AdbcError* error) {
1073 RAISE_STATUS(error, impl().ExecuteSchemaImpl(schema));
1074 return ADBC_STATUS_OK;
1075 }
1076
1077 Status ExecuteSchemaImpl(ArrowSchema* schema) {
1078 return status::NotImplemented("ExecuteSchema");
1079 }
1080
1081 AdbcStatusCode Prepare(AdbcError* error) {
1082 RAISE_STATUS(error, impl().PrepareImpl());
1083 return ADBC_STATUS_OK;
1084 }
1085
1086 Status PrepareImpl() { return status::NotImplemented("Prepare"); }
1087
1088 AdbcStatusCode SetSqlQuery(const char* query, AdbcError* error) {
1089 RAISE_STATUS(error, impl().SetSqlQueryImpl(query));
1090 return ADBC_STATUS_OK;
1091 }
1092
1093 Status SetSqlQueryImpl(std::string_view query) {
1094 return status::NotImplemented("SetSqlQuery");
1095 }
1096
1097 AdbcStatusCode SetSubstraitPlan(const uint8_t* plan, size_t length, AdbcError* error) {
1098 RAISE_STATUS(error, impl().SetSubstraitPlanImpl(std::string_view(
1099 reinterpret_cast<const char*>(plan), length)));
1100 return ADBC_STATUS_OK;
1101 }
1102
1103 Status SetSubstraitPlanImpl(std::string_view plan) {
1104 return status::NotImplemented("SetSubstraitPlan");
1105 }
1106
1107 AdbcStatusCode Bind(ArrowArray* values, ArrowSchema* schema, AdbcError* error) {
1108 RAISE_STATUS(error, impl().BindImpl(values, schema));
1109 return ADBC_STATUS_OK;
1110 }
1111
1112 Status BindImpl(ArrowArray* values, ArrowSchema* schema) {
1113 return status::NotImplemented("Bind");
1114 }
1115
1116 AdbcStatusCode BindStream(ArrowArrayStream* stream, AdbcError* error) {
1117 RAISE_STATUS(error, impl().BindStreamImpl(stream));
1118 return ADBC_STATUS_OK;
1119 }
1120
1121 Status BindStreamImpl(ArrowArrayStream* stream) {
1122 return status::NotImplemented("BindStream");
1123 }
1124
1125 AdbcStatusCode GetParameterSchema(ArrowSchema* schema, AdbcError* error) {
1126 RAISE_STATUS(error, impl().GetParameterSchemaImpl(schema));
1127 return ADBC_STATUS_OK;
1128 }
1129
1130 Status GetParameterSchemaImpl(struct ArrowSchema* schema) {
1131 return status::NotImplemented("GetParameterSchema");
1132 }
1133
1134 AdbcStatusCode ExecutePartitions(ArrowSchema* schema, AdbcPartitions* partitions,
1135 int64_t* rows_affected, AdbcError* error) {
1137 }
1138
1139 AdbcStatusCode Cancel(AdbcError* error) {
1140 RAISE_STATUS(error, impl().Cancel());
1141 return ADBC_STATUS_OK;
1142 }
1143
1144 Status Cancel() { return status::NotImplemented("Cancel"); }
1145
1146 private:
1147 Derived& impl() { return static_cast<Derived&>(*this); }
1148};
1149
1150} // namespace adbc::driver
Definition base_driver.h:827
virtual Status InitImpl(void *parent)
Initialize the database.
Definition base_driver.h:847
AdbcStatusCode SetOption(std::string_view key, Option value, AdbcError *error) override
Set an option value.
Definition base_driver.h:1007
AutocommitState
Whether autocommit is enabled or not (by default: enabled).
Definition base_driver.h:832
AdbcStatusCode Release(AdbcError *error) override
Finalize the object.
Definition base_driver.h:991
virtual Status SetOptionImpl(std::string_view key, Option value)
Set an option. May be called prior to InitImpl.
Definition base_driver.h:1014
AdbcStatusCode Init(void *parent, AdbcError *error) override
Initialize the object.
Definition base_driver.h:841
Definition base_driver.h:784
AdbcStatusCode Init(void *parent, AdbcError *error) override
Initialize the object.
Definition base_driver.h:792
virtual Status InitImpl()
Initialize the database.
Definition base_driver.h:811
AdbcStatusCode Release(AdbcError *error) override
Finalize the object.
Definition base_driver.h:798
virtual Status SetOptionImpl(std::string_view key, Option value)
Set an option. May be called prior to InitImpl.
Definition base_driver.h:817
AdbcStatusCode SetOption(std::string_view key, Option value, AdbcError *error) override
Set an option value.
Definition base_driver.h:804
virtual Status ReleaseImpl()
Release the database.
Definition base_driver.h:814
Definition base_driver.h:1024
Status InitImpl(void *parent)
Initialize the statement.
Definition base_driver.h:1035
AdbcStatusCode Release(AdbcError *error) override
Finalize the object.
Definition base_driver.h:1038
AdbcStatusCode SetOption(std::string_view key, Option value, AdbcError *error) override
Set an option value.
Definition base_driver.h:1046
AdbcStatusCode Init(void *parent, AdbcError *error) override
Initialize the object.
Definition base_driver.h:1029
virtual Status SetOptionImpl(std::string_view key, Option value)
Set an option. May be called prior to InitImpl.
Definition base_driver.h:1053
Definition base_driver.h:365
Base class for private_data of AdbcDatabase, AdbcConnection, and AdbcStatement.
Definition base_driver.h:256
virtual AdbcStatusCode SetOption(std::string_view key, Option value, AdbcError *error)
Set an option value.
Definition base_driver.h:300
virtual AdbcStatusCode Release(AdbcError *error)
Finalize the object.
Definition base_driver.h:291
virtual AdbcStatusCode Init(void *parent, AdbcError *error)
Initialize the object.
Definition base_driver.h:276
virtual Result< Option > GetOption(std::string_view key)
Get an option value.
Definition base_driver.h:294
A typed option value wrapper. It currently does not attempt conversion (i.e., getting a double option...
Definition base_driver.h:59
Option(const char *value)
Construct an option from a C string. NULL strings are treated as unset.
Definition base_driver.h:69
Result< std::string_view > AsString() const
Get the value if it is a string.
Definition base_driver.h:127
std::variant< Unset, std::string, std::vector< uint8_t >, int64_t, double > Value
The possible values of an option.
Definition base_driver.h:64
std::string Format() const
Provide a human-readable summary of the value.
Definition base_driver.h:141
Result< int64_t > AsInt() const
Try to parse a string or integer value as an integer.
Definition base_driver.h:100
Result< bool > AsBool() const
Try to parse a string value as a boolean.
Definition base_driver.h:83
bool has_value() const
Check whether this option is set.
Definition base_driver.h:80
A wrapper around a value, or an error.
Definition status.h:203
A wrapper around AdbcStatusCode + AdbcError.
Definition status.h:43
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:834
An active database connection.
Definition adbc.h:831
#define ADBC_VERSION_1_0_0
ADBC revision 1.0.0.
Definition adbc.h:401
#define ADBC_VERSION_1_1_0
ADBC revision 1.1.0.
Definition adbc.h:409
#define ADBC_OPTION_VALUE_DISABLED
Canonical option value for disabling an option.
Definition adbc.h:418
#define ADBC_OPTION_VALUE_ENABLED
Canonical option value for enabling an option.
Definition adbc.h:414
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:811
An instance of a database.
Definition adbc.h:808
void * private_data
Opaque driver-defined state. This field is NULL if the driver is unintialized/freed (but it need not ...
Definition adbc.h:940
#define ADBC_DRIVER_1_0_0_SIZE
The size of the AdbcDriver structure in ADBC 1.0.0. Drivers written for ADBC 1.1.0 and later should n...
Definition adbc.h:1094
#define ADBC_DRIVER_1_1_0_SIZE
The size of the AdbcDriver structure in ADBC 1.1.0. Drivers written for ADBC 1.1.0 and later should n...
Definition adbc.h:1102
An instance of an initialized database driver.
Definition adbc.h:936
int32_t vendor_code
A vendor-specific error code, if applicable.
Definition adbc.h:274
void * private_data
Opaque implementation-defined state.
Definition adbc.h:294
#define ADBC_ERROR_VENDOR_CODE_PRIVATE_DATA
Inform the driver/driver manager that we are using the extended AdbcError struct from ADBC 1....
Definition adbc.h:257
#define ADBC_STATUS_NOT_IMPLEMENTED
The operation is not implemented or supported.
Definition adbc.h:187
uint8_t AdbcStatusCode
Error codes for operations that may fail.
Definition adbc.h:176
#define ADBC_STATUS_OK
No error.
Definition adbc.h:179
#define ADBC_STATUS_INVALID_STATE
The preconditions for the operation are not met, likely a programming error.
Definition adbc.h:209
A detailed error message for an operation.
Definition adbc.h:269
Extra key-value metadata for an error.
Definition adbc.h:350
The partitions of a distributed/partitioned result set.
Definition adbc.h:897
void * private_data
Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
Definition adbc.h:872
A container for all state needed to execute a database query, such as the query itself,...
Definition adbc.h:869
#define RAISE_RESULT(ERROR, LHS, RHS)
A helper to unwrap a Result in functions returning AdbcStatusCode.
Definition status.h:277
#define RAISE_STATUS(ERROR, RHS)
A helper to unwrap a Status in functions returning AdbcStatusCode.
Definition status.h:280
The option is unset.
Definition base_driver.h:62
Helper for below: given the ADBC type, pick the right driver type.
Definition base_driver.h:341