duckdb 0.3.2-dev29.0 → 0.3.2-dev292.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb.cpp +30628 -20029
  3. package/src/duckdb.hpp +695 -637
package/src/duckdb.hpp CHANGED
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
10
10
 
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
- #define DUCKDB_SOURCE_ID "408ad6407"
14
- #define DUCKDB_VERSION "0.3.2-dev29"
13
+ #define DUCKDB_SOURCE_ID "43a2bb05d"
14
+ #define DUCKDB_VERSION "0.3.2-dev292"
15
15
  //===----------------------------------------------------------------------===//
16
16
  // DuckDB
17
17
  //
@@ -72,6 +72,32 @@ using std::string;
72
72
  }
73
73
 
74
74
 
75
+
76
+ #ifndef DUCKDB_API
77
+ #ifdef _WIN32
78
+ #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
79
+ #define DUCKDB_API __declspec(dllexport)
80
+ #else
81
+ #define DUCKDB_API __declspec(dllimport)
82
+ #endif
83
+ #else
84
+ #define DUCKDB_API
85
+ #endif
86
+ #endif
87
+
88
+ #ifndef DUCKDB_EXTENSION_API
89
+ #ifdef _WIN32
90
+ #ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
91
+ #define DUCKDB_EXTENSION_API __declspec(dllexport)
92
+ #else
93
+ #define DUCKDB_EXTENSION_API
94
+ #endif
95
+ #else
96
+ #define DUCKDB_EXTENSION_API
97
+ #endif
98
+ #endif
99
+
100
+
75
101
  namespace duckdb {
76
102
 
77
103
  //! inline std directives that we use frequently
@@ -96,9 +122,6 @@ typedef int64_t row_t;
96
122
  //! The type used for hashes
97
123
  typedef uint64_t hash_t;
98
124
 
99
- //! The value used to signify an invalid index entry
100
- extern const idx_t INVALID_INDEX;
101
-
102
125
  //! data pointers
103
126
  typedef uint8_t data_t;
104
127
  typedef data_t *data_ptr_t;
@@ -124,6 +147,11 @@ extern const transaction_t NOT_DELETED_ID;
124
147
 
125
148
  extern const double PI;
126
149
 
150
+ struct DConstants {
151
+ //! The value used to signify an invalid index entry
152
+ static constexpr const idx_t INVALID_INDEX = idx_t(-1);
153
+ };
154
+
127
155
  struct Storage {
128
156
  //! The size of a hard disk sector, only really needed for Direct IO
129
157
  constexpr static int SECTOR_SIZE = 4096;
@@ -198,6 +226,12 @@ enum class ProfilerPrintFormat : uint8_t { NONE, QUERY_TREE, JSON, QUERY_TREE_OP
198
226
  #define suint64_t int64_t
199
227
  #endif
200
228
 
229
+ #if defined(_WIN32) || defined(_WIN64)
230
+ #define DUCKDB_WINDOWS
231
+ #elif defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))
232
+ #define DUCKDB_POSIX
233
+ #endif
234
+
201
235
  namespace duckdb {
202
236
  #if !defined(_MSC_VER) && (__cplusplus < 201402L)
203
237
  template <typename T, typename... Args>
@@ -546,28 +580,6 @@ using std::vector;
546
580
 
547
581
 
548
582
 
549
- #ifndef DUCKDB_API
550
- #ifdef _WIN32
551
- #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
552
- #define DUCKDB_API __declspec(dllexport)
553
- #else
554
- #define DUCKDB_API __declspec(dllimport)
555
- #endif
556
- #else
557
- #define DUCKDB_API
558
- #endif
559
- #endif
560
-
561
- #ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
562
- #ifdef _WIN32
563
- #define DUCKDB_EXTENSION_API __declspec(dllexport)
564
- #else
565
- #define DUCKDB_EXTENSION_API
566
- #endif
567
- #endif
568
-
569
-
570
-
571
583
  namespace duckdb {
572
584
 
573
585
  class Serializer;
@@ -925,42 +937,38 @@ struct LogicalType {
925
937
  DUCKDB_API LogicalType();
926
938
  DUCKDB_API LogicalType(LogicalTypeId id); // NOLINT: Allow implicit conversion from `LogicalTypeId`
927
939
  DUCKDB_API LogicalType(LogicalTypeId id, shared_ptr<ExtraTypeInfo> type_info);
928
-
929
- DUCKDB_API LogicalType(const LogicalType &other) :
930
- id_(other.id_), physical_type_(other.physical_type_), type_info_(other.type_info_) {}
931
-
932
- DUCKDB_API LogicalType(LogicalType &&other) :
933
- id_(other.id_), physical_type_(other.physical_type_), type_info_(move(other.type_info_)) {}
940
+ DUCKDB_API LogicalType(const LogicalType &other);
941
+ DUCKDB_API LogicalType(LogicalType &&other) noexcept;
934
942
 
935
943
  DUCKDB_API ~LogicalType();
936
944
 
937
- LogicalTypeId id() const {
945
+ inline LogicalTypeId id() const {
938
946
  return id_;
939
947
  }
940
- PhysicalType InternalType() const {
948
+ inline PhysicalType InternalType() const {
941
949
  return physical_type_;
942
950
  }
943
- const ExtraTypeInfo *AuxInfo() const {
951
+ inline const ExtraTypeInfo *AuxInfo() const {
944
952
  return type_info_.get();
945
953
  }
946
954
 
947
955
  // copy assignment
948
- LogicalType& operator=(const LogicalType &other) {
956
+ inline LogicalType& operator=(const LogicalType &other) {
949
957
  id_ = other.id_;
950
958
  physical_type_ = other.physical_type_;
951
959
  type_info_ = other.type_info_;
952
960
  return *this;
953
961
  }
954
962
  // move assignment
955
- LogicalType& operator=(LogicalType&& other) {
963
+ inline LogicalType& operator=(LogicalType&& other) {
956
964
  id_ = other.id_;
957
965
  physical_type_ = other.physical_type_;
958
966
  type_info_ = move(other.type_info_);
959
967
  return *this;
960
968
  }
961
969
 
962
- bool operator==(const LogicalType &rhs) const;
963
- bool operator!=(const LogicalType &rhs) const {
970
+ DUCKDB_API bool operator==(const LogicalType &rhs) const;
971
+ inline bool operator!=(const LogicalType &rhs) const {
964
972
  return !(*this == rhs);
965
973
  }
966
974
 
@@ -990,34 +998,34 @@ private:
990
998
  PhysicalType GetInternalType();
991
999
 
992
1000
  public:
993
- DUCKDB_API static const LogicalType SQLNULL;
994
- DUCKDB_API static const LogicalType BOOLEAN;
995
- DUCKDB_API static const LogicalType TINYINT;
996
- DUCKDB_API static const LogicalType UTINYINT;
997
- DUCKDB_API static const LogicalType SMALLINT;
998
- DUCKDB_API static const LogicalType USMALLINT;
999
- DUCKDB_API static const LogicalType INTEGER;
1000
- DUCKDB_API static const LogicalType UINTEGER;
1001
- DUCKDB_API static const LogicalType BIGINT;
1002
- DUCKDB_API static const LogicalType UBIGINT;
1003
- DUCKDB_API static const LogicalType FLOAT;
1004
- DUCKDB_API static const LogicalType DOUBLE;
1005
- DUCKDB_API static const LogicalType DATE;
1006
- DUCKDB_API static const LogicalType TIMESTAMP;
1007
- DUCKDB_API static const LogicalType TIMESTAMP_S;
1008
- DUCKDB_API static const LogicalType TIMESTAMP_MS;
1009
- DUCKDB_API static const LogicalType TIMESTAMP_NS;
1010
- DUCKDB_API static const LogicalType TIME;
1011
- DUCKDB_API static const LogicalType VARCHAR;
1012
- DUCKDB_API static const LogicalType ANY;
1013
- DUCKDB_API static const LogicalType BLOB;
1014
- DUCKDB_API static const LogicalType INTERVAL;
1015
- DUCKDB_API static const LogicalType HUGEINT;
1016
- DUCKDB_API static const LogicalType UUID;
1017
- DUCKDB_API static const LogicalType HASH;
1018
- DUCKDB_API static const LogicalType POINTER;
1019
- DUCKDB_API static const LogicalType TABLE;
1020
- DUCKDB_API static const LogicalType INVALID;
1001
+ static constexpr const LogicalTypeId SQLNULL = LogicalTypeId::SQLNULL;
1002
+ static constexpr const LogicalTypeId BOOLEAN = LogicalTypeId::BOOLEAN;
1003
+ static constexpr const LogicalTypeId TINYINT = LogicalTypeId::TINYINT;
1004
+ static constexpr const LogicalTypeId UTINYINT = LogicalTypeId::UTINYINT;
1005
+ static constexpr const LogicalTypeId SMALLINT = LogicalTypeId::SMALLINT;
1006
+ static constexpr const LogicalTypeId USMALLINT = LogicalTypeId::USMALLINT;
1007
+ static constexpr const LogicalTypeId INTEGER = LogicalTypeId::INTEGER;
1008
+ static constexpr const LogicalTypeId UINTEGER = LogicalTypeId::UINTEGER;
1009
+ static constexpr const LogicalTypeId BIGINT = LogicalTypeId::BIGINT;
1010
+ static constexpr const LogicalTypeId UBIGINT = LogicalTypeId::UBIGINT;
1011
+ static constexpr const LogicalTypeId FLOAT = LogicalTypeId::FLOAT;
1012
+ static constexpr const LogicalTypeId DOUBLE = LogicalTypeId::DOUBLE;
1013
+ static constexpr const LogicalTypeId DATE = LogicalTypeId::DATE;
1014
+ static constexpr const LogicalTypeId TIMESTAMP = LogicalTypeId::TIMESTAMP;
1015
+ static constexpr const LogicalTypeId TIMESTAMP_S = LogicalTypeId::TIMESTAMP_SEC;
1016
+ static constexpr const LogicalTypeId TIMESTAMP_MS = LogicalTypeId::TIMESTAMP_MS;
1017
+ static constexpr const LogicalTypeId TIMESTAMP_NS = LogicalTypeId::TIMESTAMP_NS;
1018
+ static constexpr const LogicalTypeId TIME = LogicalTypeId::TIME;
1019
+ static constexpr const LogicalTypeId VARCHAR = LogicalTypeId::VARCHAR;
1020
+ static constexpr const LogicalTypeId ANY = LogicalTypeId::ANY;
1021
+ static constexpr const LogicalTypeId BLOB = LogicalTypeId::BLOB;
1022
+ static constexpr const LogicalTypeId INTERVAL = LogicalTypeId::INTERVAL;
1023
+ static constexpr const LogicalTypeId HUGEINT = LogicalTypeId::HUGEINT;
1024
+ static constexpr const LogicalTypeId UUID = LogicalTypeId::UUID;
1025
+ static constexpr const LogicalTypeId HASH = LogicalTypeId::HASH;
1026
+ static constexpr const LogicalTypeId POINTER = LogicalTypeId::POINTER;
1027
+ static constexpr const LogicalTypeId TABLE = LogicalTypeId::TABLE;
1028
+ static constexpr const LogicalTypeId INVALID = LogicalTypeId::INVALID;
1021
1029
 
1022
1030
  // explicitly allowing these functions to be capitalized to be in-line with the remaining functions
1023
1031
  DUCKDB_API static LogicalType DECIMAL(int width, int scale); // NOLINT
@@ -1158,15 +1166,9 @@ enum class ExceptionFormatValueType : uint8_t {
1158
1166
  };
1159
1167
 
1160
1168
  struct ExceptionFormatValue {
1161
- ExceptionFormatValue(double dbl_val) // NOLINT
1162
- : type(ExceptionFormatValueType::FORMAT_VALUE_TYPE_DOUBLE), dbl_val(dbl_val) {
1163
- }
1164
- ExceptionFormatValue(int64_t int_val) // NOLINT
1165
- : type(ExceptionFormatValueType::FORMAT_VALUE_TYPE_INTEGER), int_val(int_val) {
1166
- }
1167
- ExceptionFormatValue(string str_val) // NOLINT
1168
- : type(ExceptionFormatValueType::FORMAT_VALUE_TYPE_STRING), str_val(move(str_val)) {
1169
- }
1169
+ DUCKDB_API ExceptionFormatValue(double dbl_val); // NOLINT
1170
+ DUCKDB_API ExceptionFormatValue(int64_t int_val); // NOLINT
1171
+ DUCKDB_API ExceptionFormatValue(string str_val); // NOLINT
1170
1172
 
1171
1173
  ExceptionFormatValueType type;
1172
1174
 
@@ -1183,19 +1185,19 @@ public:
1183
1185
  };
1184
1186
 
1185
1187
  template <>
1186
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(PhysicalType value);
1188
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(PhysicalType value);
1187
1189
  template <>
1188
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(LogicalType value);
1190
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(LogicalType value);
1189
1191
  template <>
1190
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(float value);
1192
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(float value);
1191
1193
  template <>
1192
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(double value);
1194
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(double value);
1193
1195
  template <>
1194
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(string value);
1196
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(string value);
1195
1197
  template <>
1196
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(const char *value);
1198
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(const char *value);
1197
1199
  template <>
1198
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(char *value);
1200
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(char *value);
1199
1201
 
1200
1202
  } // namespace duckdb
1201
1203
 
@@ -1266,15 +1268,15 @@ enum class ExceptionType {
1266
1268
 
1267
1269
  class Exception : public std::exception {
1268
1270
  public:
1269
- explicit Exception(const string &msg);
1270
- Exception(ExceptionType exception_type, const string &message);
1271
+ DUCKDB_API explicit Exception(const string &msg);
1272
+ DUCKDB_API Exception(ExceptionType exception_type, const string &message);
1271
1273
 
1272
1274
  ExceptionType type;
1273
1275
 
1274
1276
  public:
1275
- const char *what() const noexcept override;
1277
+ DUCKDB_API const char *what() const noexcept override;
1276
1278
 
1277
- string ExceptionTypeToString(ExceptionType type);
1279
+ DUCKDB_API string ExceptionTypeToString(ExceptionType type);
1278
1280
 
1279
1281
  template <typename... Args>
1280
1282
  static string ConstructMessage(const string &msg, Args... params) {
@@ -1282,7 +1284,7 @@ public:
1282
1284
  return ConstructMessageRecursive(msg, values, params...);
1283
1285
  }
1284
1286
 
1285
- static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values);
1287
+ DUCKDB_API static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values);
1286
1288
 
1287
1289
  template <class T, typename... Args>
1288
1290
  static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values, T param,
@@ -1302,13 +1304,12 @@ private:
1302
1304
  //! Exceptions that are StandardExceptions do NOT invalidate the current transaction when thrown
1303
1305
  class StandardException : public Exception {
1304
1306
  public:
1305
- StandardException(ExceptionType exception_type, string message) : Exception(exception_type, message) {
1306
- }
1307
+ DUCKDB_API StandardException(ExceptionType exception_type, const string &message);
1307
1308
  };
1308
1309
 
1309
1310
  class CatalogException : public StandardException {
1310
1311
  public:
1311
- explicit CatalogException(const string &msg);
1312
+ DUCKDB_API explicit CatalogException(const string &msg);
1312
1313
 
1313
1314
  template <typename... Args>
1314
1315
  explicit CatalogException(const string &msg, Args... params) : CatalogException(ConstructMessage(msg, params...)) {
@@ -1317,7 +1318,7 @@ public:
1317
1318
 
1318
1319
  class ParserException : public StandardException {
1319
1320
  public:
1320
- explicit ParserException(const string &msg);
1321
+ DUCKDB_API explicit ParserException(const string &msg);
1321
1322
 
1322
1323
  template <typename... Args>
1323
1324
  explicit ParserException(const string &msg, Args... params) : ParserException(ConstructMessage(msg, params...)) {
@@ -1326,7 +1327,7 @@ public:
1326
1327
 
1327
1328
  class BinderException : public StandardException {
1328
1329
  public:
1329
- explicit BinderException(const string &msg);
1330
+ DUCKDB_API explicit BinderException(const string &msg);
1330
1331
 
1331
1332
  template <typename... Args>
1332
1333
  explicit BinderException(const string &msg, Args... params) : BinderException(ConstructMessage(msg, params...)) {
@@ -1335,7 +1336,7 @@ public:
1335
1336
 
1336
1337
  class ConversionException : public Exception {
1337
1338
  public:
1338
- explicit ConversionException(const string &msg);
1339
+ DUCKDB_API explicit ConversionException(const string &msg);
1339
1340
 
1340
1341
  template <typename... Args>
1341
1342
  explicit ConversionException(const string &msg, Args... params)
@@ -1345,7 +1346,7 @@ public:
1345
1346
 
1346
1347
  class TransactionException : public Exception {
1347
1348
  public:
1348
- explicit TransactionException(const string &msg);
1349
+ DUCKDB_API explicit TransactionException(const string &msg);
1349
1350
 
1350
1351
  template <typename... Args>
1351
1352
  explicit TransactionException(const string &msg, Args... params)
@@ -1355,7 +1356,7 @@ public:
1355
1356
 
1356
1357
  class NotImplementedException : public Exception {
1357
1358
  public:
1358
- explicit NotImplementedException(const string &msg);
1359
+ DUCKDB_API explicit NotImplementedException(const string &msg);
1359
1360
 
1360
1361
  template <typename... Args>
1361
1362
  explicit NotImplementedException(const string &msg, Args... params)
@@ -1365,7 +1366,7 @@ public:
1365
1366
 
1366
1367
  class OutOfRangeException : public Exception {
1367
1368
  public:
1368
- explicit OutOfRangeException(const string &msg);
1369
+ DUCKDB_API explicit OutOfRangeException(const string &msg);
1369
1370
 
1370
1371
  template <typename... Args>
1371
1372
  explicit OutOfRangeException(const string &msg, Args... params)
@@ -1375,7 +1376,7 @@ public:
1375
1376
 
1376
1377
  class OutOfMemoryException : public Exception {
1377
1378
  public:
1378
- explicit OutOfMemoryException(const string &msg);
1379
+ DUCKDB_API explicit OutOfMemoryException(const string &msg);
1379
1380
 
1380
1381
  template <typename... Args>
1381
1382
  explicit OutOfMemoryException(const string &msg, Args... params)
@@ -1385,7 +1386,7 @@ public:
1385
1386
 
1386
1387
  class SyntaxException : public Exception {
1387
1388
  public:
1388
- explicit SyntaxException(const string &msg);
1389
+ DUCKDB_API explicit SyntaxException(const string &msg);
1389
1390
 
1390
1391
  template <typename... Args>
1391
1392
  explicit SyntaxException(const string &msg, Args... params) : SyntaxException(ConstructMessage(msg, params...)) {
@@ -1394,7 +1395,7 @@ public:
1394
1395
 
1395
1396
  class ConstraintException : public Exception {
1396
1397
  public:
1397
- explicit ConstraintException(const string &msg);
1398
+ DUCKDB_API explicit ConstraintException(const string &msg);
1398
1399
 
1399
1400
  template <typename... Args>
1400
1401
  explicit ConstraintException(const string &msg, Args... params)
@@ -1404,7 +1405,7 @@ public:
1404
1405
 
1405
1406
  class IOException : public Exception {
1406
1407
  public:
1407
- explicit IOException(const string &msg);
1408
+ DUCKDB_API explicit IOException(const string &msg);
1408
1409
 
1409
1410
  template <typename... Args>
1410
1411
  explicit IOException(const string &msg, Args... params) : IOException(ConstructMessage(msg, params...)) {
@@ -1413,7 +1414,7 @@ public:
1413
1414
 
1414
1415
  class SerializationException : public Exception {
1415
1416
  public:
1416
- explicit SerializationException(const string &msg);
1417
+ DUCKDB_API explicit SerializationException(const string &msg);
1417
1418
 
1418
1419
  template <typename... Args>
1419
1420
  explicit SerializationException(const string &msg, Args... params)
@@ -1423,7 +1424,7 @@ public:
1423
1424
 
1424
1425
  class SequenceException : public Exception {
1425
1426
  public:
1426
- explicit SequenceException(const string &msg);
1427
+ DUCKDB_API explicit SequenceException(const string &msg);
1427
1428
 
1428
1429
  template <typename... Args>
1429
1430
  explicit SequenceException(const string &msg, Args... params)
@@ -1433,12 +1434,12 @@ public:
1433
1434
 
1434
1435
  class InterruptException : public Exception {
1435
1436
  public:
1436
- InterruptException();
1437
+ DUCKDB_API InterruptException();
1437
1438
  };
1438
1439
 
1439
1440
  class FatalException : public Exception {
1440
1441
  public:
1441
- explicit FatalException(const string &msg);
1442
+ DUCKDB_API explicit FatalException(const string &msg);
1442
1443
 
1443
1444
  template <typename... Args>
1444
1445
  explicit FatalException(const string &msg, Args... params) : FatalException(ConstructMessage(msg, params...)) {
@@ -1447,7 +1448,7 @@ public:
1447
1448
 
1448
1449
  class InternalException : public Exception {
1449
1450
  public:
1450
- explicit InternalException(const string &msg);
1451
+ DUCKDB_API explicit InternalException(const string &msg);
1451
1452
 
1452
1453
  template <typename... Args>
1453
1454
  explicit InternalException(const string &msg, Args... params)
@@ -1457,7 +1458,7 @@ public:
1457
1458
 
1458
1459
  class InvalidInputException : public Exception {
1459
1460
  public:
1460
- explicit InvalidInputException(const string &msg);
1461
+ DUCKDB_API explicit InvalidInputException(const string &msg);
1461
1462
 
1462
1463
  template <typename... Args>
1463
1464
  explicit InvalidInputException(const string &msg, Args... params)
@@ -1467,28 +1468,28 @@ public:
1467
1468
 
1468
1469
  class CastException : public Exception {
1469
1470
  public:
1470
- CastException(const PhysicalType origType, const PhysicalType newType);
1471
- CastException(const LogicalType &origType, const LogicalType &newType);
1471
+ DUCKDB_API CastException(const PhysicalType origType, const PhysicalType newType);
1472
+ DUCKDB_API CastException(const LogicalType &origType, const LogicalType &newType);
1472
1473
  };
1473
1474
 
1474
1475
  class InvalidTypeException : public Exception {
1475
1476
  public:
1476
- InvalidTypeException(PhysicalType type, const string &msg);
1477
- InvalidTypeException(const LogicalType &type, const string &msg);
1477
+ DUCKDB_API InvalidTypeException(PhysicalType type, const string &msg);
1478
+ DUCKDB_API InvalidTypeException(const LogicalType &type, const string &msg);
1478
1479
  };
1479
1480
 
1480
1481
  class TypeMismatchException : public Exception {
1481
1482
  public:
1482
- TypeMismatchException(const PhysicalType type_1, const PhysicalType type_2, const string &msg);
1483
- TypeMismatchException(const LogicalType &type_1, const LogicalType &type_2, const string &msg);
1483
+ DUCKDB_API TypeMismatchException(const PhysicalType type_1, const PhysicalType type_2, const string &msg);
1484
+ DUCKDB_API TypeMismatchException(const LogicalType &type_1, const LogicalType &type_2, const string &msg);
1484
1485
  };
1485
1486
 
1486
1487
  class ValueOutOfRangeException : public Exception {
1487
1488
  public:
1488
- ValueOutOfRangeException(const int64_t value, const PhysicalType origType, const PhysicalType newType);
1489
- ValueOutOfRangeException(const hugeint_t value, const PhysicalType origType, const PhysicalType newType);
1490
- ValueOutOfRangeException(const double value, const PhysicalType origType, const PhysicalType newType);
1491
- ValueOutOfRangeException(const PhysicalType varType, const idx_t length);
1489
+ DUCKDB_API ValueOutOfRangeException(const int64_t value, const PhysicalType origType, const PhysicalType newType);
1490
+ DUCKDB_API ValueOutOfRangeException(const hugeint_t value, const PhysicalType origType, const PhysicalType newType);
1491
+ DUCKDB_API ValueOutOfRangeException(const double value, const PhysicalType origType, const PhysicalType newType);
1492
+ DUCKDB_API ValueOutOfRangeException(const PhysicalType varType, const idx_t length);
1492
1493
  };
1493
1494
 
1494
1495
  } // namespace duckdb
@@ -1923,6 +1924,7 @@ public:
1923
1924
  FileOpener *opener = nullptr);
1924
1925
 
1925
1926
  FileSystem &fs;
1927
+ string path;
1926
1928
  unique_ptr<data_t[]> data;
1927
1929
  idx_t offset;
1928
1930
  idx_t total_written;
@@ -2224,14 +2226,14 @@ struct TemplatedValidityData {
2224
2226
  static constexpr const V MAX_ENTRY = ~V(0);
2225
2227
 
2226
2228
  public:
2227
- explicit TemplatedValidityData(idx_t count) {
2229
+ DUCKDB_API explicit TemplatedValidityData(idx_t count) {
2228
2230
  auto entry_count = EntryCount(count);
2229
2231
  owned_data = unique_ptr<V[]>(new V[entry_count]);
2230
2232
  for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
2231
2233
  owned_data[entry_idx] = MAX_ENTRY;
2232
2234
  }
2233
2235
  }
2234
- TemplatedValidityData(const V *validity_mask, idx_t count) {
2236
+ DUCKDB_API TemplatedValidityData(const V *validity_mask, idx_t count) {
2235
2237
  D_ASSERT(validity_mask);
2236
2238
  auto entry_count = EntryCount(count);
2237
2239
  owned_data = unique_ptr<V[]>(new V[entry_count]);
@@ -2243,7 +2245,7 @@ public:
2243
2245
  unique_ptr<V[]> owned_data;
2244
2246
 
2245
2247
  public:
2246
- static inline idx_t EntryCount(idx_t count) {
2248
+ DUCKDB_API static inline idx_t EntryCount(idx_t count) {
2247
2249
  return (count + (BITS_PER_VALUE - 1)) / BITS_PER_VALUE;
2248
2250
  }
2249
2251
  };
@@ -2267,24 +2269,24 @@ public:
2267
2269
  static constexpr const int STANDARD_MASK_SIZE = STANDARD_ENTRY_COUNT * sizeof(validity_t);
2268
2270
 
2269
2271
  public:
2270
- TemplatedValidityMask() : validity_mask(nullptr) {
2272
+ DUCKDB_API TemplatedValidityMask() : validity_mask(nullptr) {
2271
2273
  }
2272
- explicit TemplatedValidityMask(idx_t max_count) {
2274
+ DUCKDB_API explicit TemplatedValidityMask(idx_t max_count) {
2273
2275
  Initialize(max_count);
2274
2276
  }
2275
- explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
2277
+ DUCKDB_API explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
2276
2278
  }
2277
- TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
2279
+ DUCKDB_API TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
2278
2280
  Copy(original, count);
2279
2281
  }
2280
2282
 
2281
- static inline idx_t ValidityMaskSize(idx_t count = STANDARD_VECTOR_SIZE) {
2283
+ DUCKDB_API static inline idx_t ValidityMaskSize(idx_t count = STANDARD_VECTOR_SIZE) {
2282
2284
  return ValidityBuffer::EntryCount(count) * sizeof(V);
2283
2285
  }
2284
- inline bool AllValid() const {
2286
+ DUCKDB_API inline bool AllValid() const {
2285
2287
  return !validity_mask;
2286
2288
  }
2287
- bool CheckAllValid(idx_t count) const {
2289
+ DUCKDB_API bool CheckAllValid(idx_t count) const {
2288
2290
  if (AllValid()) {
2289
2291
  return true;
2290
2292
  }
@@ -2296,7 +2298,7 @@ public:
2296
2298
  return valid_count == entry_count;
2297
2299
  }
2298
2300
 
2299
- bool CheckAllValid(idx_t to, idx_t from) const {
2301
+ DUCKDB_API bool CheckAllValid(idx_t to, idx_t from) const {
2300
2302
  if (AllValid()) {
2301
2303
  return true;
2302
2304
  }
@@ -2308,40 +2310,40 @@ public:
2308
2310
  return true;
2309
2311
  }
2310
2312
 
2311
- inline V *GetData() const {
2313
+ DUCKDB_API inline V *GetData() const {
2312
2314
  return validity_mask;
2313
2315
  }
2314
- void Reset() {
2316
+ DUCKDB_API void Reset() {
2315
2317
  validity_mask = nullptr;
2316
2318
  validity_data.reset();
2317
2319
  }
2318
2320
 
2319
- static inline idx_t EntryCount(idx_t count) {
2321
+ DUCKDB_API static inline idx_t EntryCount(idx_t count) {
2320
2322
  return ValidityBuffer::EntryCount(count);
2321
2323
  }
2322
- inline V GetValidityEntry(idx_t entry_idx) const {
2324
+ DUCKDB_API inline V GetValidityEntry(idx_t entry_idx) const {
2323
2325
  if (!validity_mask) {
2324
2326
  return ValidityBuffer::MAX_ENTRY;
2325
2327
  }
2326
2328
  return validity_mask[entry_idx];
2327
2329
  }
2328
- static inline bool AllValid(V entry) {
2330
+ DUCKDB_API static inline bool AllValid(V entry) {
2329
2331
  return entry == ValidityBuffer::MAX_ENTRY;
2330
2332
  }
2331
- static inline bool NoneValid(V entry) {
2333
+ DUCKDB_API static inline bool NoneValid(V entry) {
2332
2334
  return entry == 0;
2333
2335
  }
2334
- static inline bool RowIsValid(V entry, idx_t idx_in_entry) {
2336
+ DUCKDB_API static inline bool RowIsValid(V entry, idx_t idx_in_entry) {
2335
2337
  return entry & (V(1) << V(idx_in_entry));
2336
2338
  }
2337
- static inline void GetEntryIndex(idx_t row_idx, idx_t &entry_idx, idx_t &idx_in_entry) {
2339
+ DUCKDB_API static inline void GetEntryIndex(idx_t row_idx, idx_t &entry_idx, idx_t &idx_in_entry) {
2338
2340
  entry_idx = row_idx / BITS_PER_VALUE;
2339
2341
  idx_in_entry = row_idx % BITS_PER_VALUE;
2340
2342
  }
2341
2343
 
2342
2344
  //! RowIsValidUnsafe should only be used if AllValid() is false: it achieves the same as RowIsValid but skips a
2343
2345
  //! not-null check
2344
- inline bool RowIsValidUnsafe(idx_t row_idx) const {
2346
+ DUCKDB_API inline bool RowIsValidUnsafe(idx_t row_idx) const {
2345
2347
  D_ASSERT(validity_mask);
2346
2348
  idx_t entry_idx, idx_in_entry;
2347
2349
  GetEntryIndex(row_idx, entry_idx, idx_in_entry);
@@ -2350,7 +2352,7 @@ public:
2350
2352
  }
2351
2353
 
2352
2354
  //! Returns true if a row is valid (i.e. not null), false otherwise
2353
- inline bool RowIsValid(idx_t row_idx) const {
2355
+ DUCKDB_API inline bool RowIsValid(idx_t row_idx) const {
2354
2356
  if (!validity_mask) {
2355
2357
  return true;
2356
2358
  }
@@ -2358,7 +2360,7 @@ public:
2358
2360
  }
2359
2361
 
2360
2362
  //! Same as SetValid, but skips a null check on validity_mask
2361
- inline void SetValidUnsafe(idx_t row_idx) {
2363
+ DUCKDB_API inline void SetValidUnsafe(idx_t row_idx) {
2362
2364
  D_ASSERT(validity_mask);
2363
2365
  idx_t entry_idx, idx_in_entry;
2364
2366
  GetEntryIndex(row_idx, entry_idx, idx_in_entry);
@@ -2366,7 +2368,7 @@ public:
2366
2368
  }
2367
2369
 
2368
2370
  //! Marks the entry at the specified row index as valid (i.e. not-null)
2369
- inline void SetValid(idx_t row_idx) {
2371
+ DUCKDB_API inline void SetValid(idx_t row_idx) {
2370
2372
  if (!validity_mask) {
2371
2373
  // if AllValid() we don't need to do anything
2372
2374
  // the row is already valid
@@ -2376,20 +2378,20 @@ public:
2376
2378
  }
2377
2379
 
2378
2380
  //! Marks the bit at the specified entry as invalid (i.e. null)
2379
- inline void SetInvalidUnsafe(idx_t entry_idx, idx_t idx_in_entry) {
2381
+ DUCKDB_API inline void SetInvalidUnsafe(idx_t entry_idx, idx_t idx_in_entry) {
2380
2382
  D_ASSERT(validity_mask);
2381
2383
  validity_mask[entry_idx] &= ~(V(1) << V(idx_in_entry));
2382
2384
  }
2383
2385
 
2384
2386
  //! Marks the bit at the specified row index as invalid (i.e. null)
2385
- inline void SetInvalidUnsafe(idx_t row_idx) {
2387
+ DUCKDB_API inline void SetInvalidUnsafe(idx_t row_idx) {
2386
2388
  idx_t entry_idx, idx_in_entry;
2387
2389
  GetEntryIndex(row_idx, entry_idx, idx_in_entry);
2388
2390
  SetInvalidUnsafe(entry_idx, idx_in_entry);
2389
2391
  }
2390
2392
 
2391
2393
  //! Marks the entry at the specified row index as invalid (i.e. null)
2392
- inline void SetInvalid(idx_t row_idx) {
2394
+ DUCKDB_API inline void SetInvalid(idx_t row_idx) {
2393
2395
  if (!validity_mask) {
2394
2396
  D_ASSERT(row_idx <= STANDARD_VECTOR_SIZE);
2395
2397
  Initialize(STANDARD_VECTOR_SIZE);
@@ -2398,7 +2400,7 @@ public:
2398
2400
  }
2399
2401
 
2400
2402
  //! Mark the entry at the specified index as either valid or invalid (non-null or null)
2401
- inline void Set(idx_t row_idx, bool valid) {
2403
+ DUCKDB_API inline void Set(idx_t row_idx, bool valid) {
2402
2404
  if (valid) {
2403
2405
  SetValid(row_idx);
2404
2406
  } else {
@@ -2407,14 +2409,14 @@ public:
2407
2409
  }
2408
2410
 
2409
2411
  //! Ensure the validity mask is writable, allocating space if it is not initialized
2410
- inline void EnsureWritable() {
2412
+ DUCKDB_API inline void EnsureWritable() {
2411
2413
  if (!validity_mask) {
2412
2414
  Initialize();
2413
2415
  }
2414
2416
  }
2415
2417
 
2416
2418
  //! Marks "count" entries in the validity mask as invalid (null)
2417
- inline void SetAllInvalid(idx_t count) {
2419
+ DUCKDB_API inline void SetAllInvalid(idx_t count) {
2418
2420
  EnsureWritable();
2419
2421
  for (idx_t i = 0; i < ValidityBuffer::EntryCount(count); i++) {
2420
2422
  validity_mask[i] = 0;
@@ -2422,14 +2424,14 @@ public:
2422
2424
  }
2423
2425
 
2424
2426
  //! Marks "count" entries in the validity mask as valid (not null)
2425
- inline void SetAllValid(idx_t count) {
2427
+ DUCKDB_API inline void SetAllValid(idx_t count) {
2426
2428
  EnsureWritable();
2427
2429
  for (idx_t i = 0; i < ValidityBuffer::EntryCount(count); i++) {
2428
2430
  validity_mask[i] = ValidityBuffer::MAX_ENTRY;
2429
2431
  }
2430
2432
  }
2431
2433
 
2432
- inline bool IsMaskSet() const {
2434
+ DUCKDB_API inline bool IsMaskSet() const {
2433
2435
  if (validity_mask) {
2434
2436
  return true;
2435
2437
  }
@@ -2437,19 +2439,19 @@ public:
2437
2439
  }
2438
2440
 
2439
2441
  public:
2440
- void Initialize(validity_t *validity) {
2442
+ DUCKDB_API void Initialize(validity_t *validity) {
2441
2443
  validity_data.reset();
2442
2444
  validity_mask = validity;
2443
2445
  }
2444
- void Initialize(const TemplatedValidityMask &other) {
2446
+ DUCKDB_API void Initialize(const TemplatedValidityMask &other) {
2445
2447
  validity_mask = other.validity_mask;
2446
2448
  validity_data = other.validity_data;
2447
2449
  }
2448
- void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
2450
+ DUCKDB_API void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
2449
2451
  validity_data = make_buffer<ValidityBuffer>(count);
2450
2452
  validity_mask = validity_data->owned_data.get();
2451
2453
  }
2452
- void Copy(const TemplatedValidityMask &other, idx_t count) {
2454
+ DUCKDB_API void Copy(const TemplatedValidityMask &other, idx_t count) {
2453
2455
  if (other.AllValid()) {
2454
2456
  validity_data = nullptr;
2455
2457
  validity_mask = nullptr;
@@ -2466,21 +2468,21 @@ protected:
2466
2468
 
2467
2469
  struct ValidityMask : public TemplatedValidityMask<validity_t> {
2468
2470
  public:
2469
- ValidityMask() : TemplatedValidityMask(nullptr) {
2471
+ DUCKDB_API ValidityMask() : TemplatedValidityMask(nullptr) {
2470
2472
  }
2471
- explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
2473
+ DUCKDB_API explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
2472
2474
  }
2473
- explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
2475
+ DUCKDB_API explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
2474
2476
  }
2475
- ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
2477
+ DUCKDB_API ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
2476
2478
  }
2477
2479
 
2478
2480
  public:
2479
- void Resize(idx_t old_size, idx_t new_size);
2481
+ DUCKDB_API void Resize(idx_t old_size, idx_t new_size);
2480
2482
 
2481
- void Slice(const ValidityMask &other, idx_t offset);
2482
- void Combine(const ValidityMask &other, idx_t count);
2483
- string ToString(idx_t count) const;
2483
+ DUCKDB_API void Slice(const ValidityMask &other, idx_t offset);
2484
+ DUCKDB_API void Combine(const ValidityMask &other, idx_t count);
2485
+ DUCKDB_API string ToString(idx_t count) const;
2484
2486
  };
2485
2487
 
2486
2488
  } // namespace duckdb
@@ -2512,25 +2514,25 @@ class Value {
2512
2514
 
2513
2515
  public:
2514
2516
  //! Create an empty NULL value of the specified type
2515
- explicit Value(LogicalType type = LogicalType::SQLNULL);
2517
+ DUCKDB_API explicit Value(LogicalType type = LogicalType::SQLNULL);
2516
2518
  //! Create an INTEGER value
2517
- Value(int32_t val); // NOLINT: Allow implicit conversion from `int32_t`
2519
+ DUCKDB_API Value(int32_t val); // NOLINT: Allow implicit conversion from `int32_t`
2518
2520
  //! Create a BIGINT value
2519
- Value(int64_t val); // NOLINT: Allow implicit conversion from `int64_t`
2521
+ DUCKDB_API Value(int64_t val); // NOLINT: Allow implicit conversion from `int64_t`
2520
2522
  //! Create a FLOAT value
2521
- Value(float val); // NOLINT: Allow implicit conversion from `float`
2523
+ DUCKDB_API Value(float val); // NOLINT: Allow implicit conversion from `float`
2522
2524
  //! Create a DOUBLE value
2523
- Value(double val); // NOLINT: Allow implicit conversion from `double`
2525
+ DUCKDB_API Value(double val); // NOLINT: Allow implicit conversion from `double`
2524
2526
  //! Create a VARCHAR value
2525
- Value(const char *val); // NOLINT: Allow implicit conversion from `const char *`
2527
+ DUCKDB_API Value(const char *val); // NOLINT: Allow implicit conversion from `const char *`
2526
2528
  //! Create a NULL value
2527
- Value(std::nullptr_t val); // NOLINT: Allow implicit conversion from `nullptr_t`
2529
+ DUCKDB_API Value(std::nullptr_t val); // NOLINT: Allow implicit conversion from `nullptr_t`
2528
2530
  //! Create a VARCHAR value
2529
- Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2531
+ DUCKDB_API Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2530
2532
  //! Create a VARCHAR value
2531
- Value(string val); // NOLINT: Allow implicit conversion from `string`
2533
+ DUCKDB_API Value(string val); // NOLINT: Allow implicit conversion from `string`
2532
2534
 
2533
- const LogicalType &type() const {
2535
+ inline const LogicalType &type() const {
2534
2536
  return type_;
2535
2537
  }
2536
2538
 
@@ -2661,32 +2663,32 @@ public:
2661
2663
  //===--------------------------------------------------------------------===//
2662
2664
  // Numeric Operators
2663
2665
  //===--------------------------------------------------------------------===//
2664
- Value operator+(const Value &rhs) const;
2665
- Value operator-(const Value &rhs) const;
2666
- Value operator*(const Value &rhs) const;
2667
- Value operator/(const Value &rhs) const;
2668
- Value operator%(const Value &rhs) const;
2666
+ DUCKDB_API Value operator+(const Value &rhs) const;
2667
+ DUCKDB_API Value operator-(const Value &rhs) const;
2668
+ DUCKDB_API Value operator*(const Value &rhs) const;
2669
+ DUCKDB_API Value operator/(const Value &rhs) const;
2670
+ DUCKDB_API Value operator%(const Value &rhs) const;
2669
2671
 
2670
2672
  //===--------------------------------------------------------------------===//
2671
2673
  // Comparison Operators
2672
2674
  //===--------------------------------------------------------------------===//
2673
- bool operator==(const Value &rhs) const;
2674
- bool operator!=(const Value &rhs) const;
2675
- bool operator<(const Value &rhs) const;
2676
- bool operator>(const Value &rhs) const;
2677
- bool operator<=(const Value &rhs) const;
2678
- bool operator>=(const Value &rhs) const;
2679
-
2680
- bool operator==(const int64_t &rhs) const;
2681
- bool operator!=(const int64_t &rhs) const;
2682
- bool operator<(const int64_t &rhs) const;
2683
- bool operator>(const int64_t &rhs) const;
2684
- bool operator<=(const int64_t &rhs) const;
2685
- bool operator>=(const int64_t &rhs) const;
2686
-
2687
- static bool FloatIsValid(float value);
2688
- static bool DoubleIsValid(double value);
2689
- static bool StringIsValid(const char *str, idx_t length);
2675
+ DUCKDB_API bool operator==(const Value &rhs) const;
2676
+ DUCKDB_API bool operator!=(const Value &rhs) const;
2677
+ DUCKDB_API bool operator<(const Value &rhs) const;
2678
+ DUCKDB_API bool operator>(const Value &rhs) const;
2679
+ DUCKDB_API bool operator<=(const Value &rhs) const;
2680
+ DUCKDB_API bool operator>=(const Value &rhs) const;
2681
+
2682
+ DUCKDB_API bool operator==(const int64_t &rhs) const;
2683
+ DUCKDB_API bool operator!=(const int64_t &rhs) const;
2684
+ DUCKDB_API bool operator<(const int64_t &rhs) const;
2685
+ DUCKDB_API bool operator>(const int64_t &rhs) const;
2686
+ DUCKDB_API bool operator<=(const int64_t &rhs) const;
2687
+ DUCKDB_API bool operator>=(const int64_t &rhs) const;
2688
+
2689
+ DUCKDB_API static bool FloatIsValid(float value);
2690
+ DUCKDB_API static bool DoubleIsValid(double value);
2691
+ DUCKDB_API static bool StringIsValid(const char *str, idx_t length);
2690
2692
  static bool StringIsValid(const string &str) {
2691
2693
  return StringIsValid(str.c_str(), str.size());
2692
2694
  }
@@ -2698,13 +2700,13 @@ public:
2698
2700
 
2699
2701
  //! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
2700
2702
  //! function, NULL values are equivalent and floating point values that are close are equivalent.
2701
- static bool ValuesAreEqual(const Value &result_value, const Value &value);
2703
+ DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
2702
2704
 
2703
2705
  friend std::ostream &operator<<(std::ostream &out, const Value &val) {
2704
2706
  out << val.ToString();
2705
2707
  return out;
2706
2708
  }
2707
- void Print() const;
2709
+ DUCKDB_API void Print() const;
2708
2710
 
2709
2711
  private:
2710
2712
  //! The logical of the value
@@ -3283,69 +3285,69 @@ class Vector {
3283
3285
 
3284
3286
  public:
3285
3287
  //! Create a vector that references the other vector
3286
- explicit Vector(Vector &other);
3288
+ DUCKDB_API explicit Vector(Vector &other);
3287
3289
  //! Create a vector that slices another vector
3288
- explicit Vector(Vector &other, const SelectionVector &sel, idx_t count);
3290
+ DUCKDB_API explicit Vector(Vector &other, const SelectionVector &sel, idx_t count);
3289
3291
  //! Create a vector that slices another vector starting from a specific offset
3290
- explicit Vector(Vector &other, idx_t offset);
3292
+ DUCKDB_API explicit Vector(Vector &other, idx_t offset);
3291
3293
  //! Create a vector of size one holding the passed on value
3292
- explicit Vector(const Value &value);
3294
+ DUCKDB_API explicit Vector(const Value &value);
3293
3295
  //! Create a vector of size tuple_count (non-standard)
3294
- explicit Vector(LogicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3296
+ DUCKDB_API explicit Vector(LogicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3295
3297
  //! Create an empty standard vector with a type, equivalent to calling Vector(type, true, false)
3296
- explicit Vector(const VectorCache &cache);
3298
+ DUCKDB_API explicit Vector(const VectorCache &cache);
3297
3299
  //! Create a non-owning vector that references the specified data
3298
- Vector(LogicalType type, data_ptr_t dataptr);
3300
+ DUCKDB_API Vector(LogicalType type, data_ptr_t dataptr);
3299
3301
  //! Create an owning vector that holds at most STANDARD_VECTOR_SIZE entries.
3300
3302
  /*!
3301
3303
  Create a new vector
3302
3304
  If create_data is true, the vector will be an owning empty vector.
3303
3305
  If zero_data is true, the allocated data will be zero-initialized.
3304
3306
  */
3305
- Vector(LogicalType type, bool create_data, bool zero_data, idx_t capacity = STANDARD_VECTOR_SIZE);
3307
+ DUCKDB_API Vector(LogicalType type, bool create_data, bool zero_data, idx_t capacity = STANDARD_VECTOR_SIZE);
3306
3308
  // implicit copying of Vectors is not allowed
3307
- Vector(const Vector &) = delete;
3309
+ DUCKDB_API Vector(const Vector &) = delete;
3308
3310
  // but moving of vectors is allowed
3309
- Vector(Vector &&other) noexcept;
3311
+ DUCKDB_API Vector(Vector &&other) noexcept;
3310
3312
 
3311
3313
  public:
3312
3314
  //! Create a vector that references the specified value.
3313
- void Reference(const Value &value);
3315
+ DUCKDB_API void Reference(const Value &value);
3314
3316
  //! Causes this vector to reference the data held by the other vector.
3315
3317
  //! The type of the "other" vector should match the type of this vector
3316
- void Reference(Vector &other);
3318
+ DUCKDB_API void Reference(Vector &other);
3317
3319
  //! Reinterpret the data of the other vector as the type of this vector
3318
3320
  //! Note that this takes the data of the other vector as-is and places it in this vector
3319
3321
  //! Without changing the type of this vector
3320
- void Reinterpret(Vector &other);
3322
+ DUCKDB_API void Reinterpret(Vector &other);
3321
3323
 
3322
3324
  //! Causes this vector to reference the data held by the other vector, changes the type if required.
3323
- void ReferenceAndSetType(Vector &other);
3325
+ DUCKDB_API void ReferenceAndSetType(Vector &other);
3324
3326
 
3325
3327
  //! Resets a vector from a vector cache.
3326
3328
  //! This turns the vector back into an empty FlatVector with STANDARD_VECTOR_SIZE entries.
3327
3329
  //! The VectorCache is used so this can be done without requiring any allocations.
3328
- void ResetFromCache(const VectorCache &cache);
3330
+ DUCKDB_API void ResetFromCache(const VectorCache &cache);
3329
3331
 
3330
3332
  //! Creates a reference to a slice of the other vector
3331
- void Slice(Vector &other, idx_t offset);
3333
+ DUCKDB_API void Slice(Vector &other, idx_t offset);
3332
3334
  //! Creates a reference to a slice of the other vector
3333
- void Slice(Vector &other, const SelectionVector &sel, idx_t count);
3335
+ DUCKDB_API void Slice(Vector &other, const SelectionVector &sel, idx_t count);
3334
3336
  //! Turns the vector into a dictionary vector with the specified dictionary
3335
- void Slice(const SelectionVector &sel, idx_t count);
3337
+ DUCKDB_API void Slice(const SelectionVector &sel, idx_t count);
3336
3338
  //! Slice the vector, keeping the result around in a cache or potentially using the cache instead of slicing
3337
- void Slice(const SelectionVector &sel, idx_t count, SelCache &cache);
3339
+ DUCKDB_API void Slice(const SelectionVector &sel, idx_t count, SelCache &cache);
3338
3340
 
3339
3341
  //! Creates the data of this vector with the specified type. Any data that
3340
3342
  //! is currently in the vector is destroyed.
3341
- void Initialize(bool zero_data = false, idx_t capacity = STANDARD_VECTOR_SIZE);
3343
+ DUCKDB_API void Initialize(bool zero_data = false, idx_t capacity = STANDARD_VECTOR_SIZE);
3342
3344
 
3343
3345
  //! Converts this Vector to a printable string representation
3344
- string ToString(idx_t count) const;
3345
- void Print(idx_t count);
3346
+ DUCKDB_API string ToString(idx_t count) const;
3347
+ DUCKDB_API void Print(idx_t count);
3346
3348
 
3347
- string ToString() const;
3348
- void Print();
3349
+ DUCKDB_API string ToString() const;
3350
+ DUCKDB_API void Print();
3349
3351
 
3350
3352
  //! Flatten the vector, removing any compression and turning it into a FLAT_VECTOR
3351
3353
  DUCKDB_API void Normalify(idx_t count);
@@ -3354,31 +3356,31 @@ public:
3354
3356
  DUCKDB_API void Orrify(idx_t count, VectorData &data);
3355
3357
 
3356
3358
  //! Turn the vector into a sequence vector
3357
- void Sequence(int64_t start, int64_t increment);
3359
+ DUCKDB_API void Sequence(int64_t start, int64_t increment);
3358
3360
 
3359
3361
  //! Verify that the Vector is in a consistent, not corrupt state. DEBUG
3360
3362
  //! FUNCTION ONLY!
3361
- void Verify(idx_t count);
3362
- void Verify(const SelectionVector &sel, idx_t count);
3363
- void UTFVerify(idx_t count);
3364
- void UTFVerify(const SelectionVector &sel, idx_t count);
3363
+ DUCKDB_API void Verify(idx_t count);
3364
+ DUCKDB_API void Verify(const SelectionVector &sel, idx_t count);
3365
+ DUCKDB_API void UTFVerify(idx_t count);
3366
+ DUCKDB_API void UTFVerify(const SelectionVector &sel, idx_t count);
3365
3367
 
3366
3368
  //! Returns the [index] element of the Vector as a Value.
3367
- Value GetValue(idx_t index) const;
3369
+ DUCKDB_API Value GetValue(idx_t index) const;
3368
3370
  //! Sets the [index] element of the Vector to the specified Value.
3369
- void SetValue(idx_t index, const Value &val);
3371
+ DUCKDB_API void SetValue(idx_t index, const Value &val);
3370
3372
 
3371
- void SetAuxiliary(buffer_ptr<VectorBuffer> new_buffer) {
3373
+ inline void SetAuxiliary(buffer_ptr<VectorBuffer> new_buffer) {
3372
3374
  auxiliary = std::move(new_buffer);
3373
3375
  };
3374
3376
 
3375
3377
  //! This functions resizes the vector
3376
- void Resize(idx_t cur_size, idx_t new_size);
3378
+ DUCKDB_API void Resize(idx_t cur_size, idx_t new_size);
3377
3379
 
3378
3380
  //! Serializes a Vector to a stand-alone binary blob
3379
- void Serialize(idx_t count, Serializer &serializer);
3381
+ DUCKDB_API void Serialize(idx_t count, Serializer &serializer);
3380
3382
  //! Deserializes a blob back into a Vector
3381
- void Deserialize(idx_t count, Deserializer &source);
3383
+ DUCKDB_API void Deserialize(idx_t count, Deserializer &source);
3382
3384
 
3383
3385
  // Getters
3384
3386
  inline VectorType GetVectorType() const {
@@ -3391,11 +3393,11 @@ public:
3391
3393
  return data;
3392
3394
  }
3393
3395
 
3394
- buffer_ptr<VectorBuffer> GetAuxiliary() {
3396
+ inline buffer_ptr<VectorBuffer> GetAuxiliary() {
3395
3397
  return auxiliary;
3396
3398
  }
3397
3399
 
3398
- buffer_ptr<VectorBuffer> GetBuffer() {
3400
+ inline buffer_ptr<VectorBuffer> GetBuffer() {
3399
3401
  return buffer;
3400
3402
  }
3401
3403
 
@@ -3646,8 +3648,8 @@ class VectorCache;
3646
3648
  class DataChunk {
3647
3649
  public:
3648
3650
  //! Creates an empty DataChunk
3649
- DataChunk();
3650
- ~DataChunk();
3651
+ DUCKDB_API DataChunk();
3652
+ DUCKDB_API ~DataChunk();
3651
3653
 
3652
3654
  //! The vectors owned by the DataChunk.
3653
3655
  vector<Vector> data;
@@ -3659,14 +3661,14 @@ public:
3659
3661
  DUCKDB_API idx_t ColumnCount() const {
3660
3662
  return data.size();
3661
3663
  }
3662
- void SetCardinality(idx_t count_p) {
3664
+ inline void SetCardinality(idx_t count_p) {
3663
3665
  D_ASSERT(count_p <= capacity);
3664
3666
  this->count = count_p;
3665
3667
  }
3666
- void SetCardinality(const DataChunk &other) {
3668
+ inline void SetCardinality(const DataChunk &other) {
3667
3669
  this->count = other.size();
3668
3670
  }
3669
- void SetCapacity(const DataChunk &other) {
3671
+ inline void SetCapacity(const DataChunk &other) {
3670
3672
  this->capacity = other.capacity;
3671
3673
  }
3672
3674
 
@@ -3682,9 +3684,9 @@ public:
3682
3684
  //! This will create one vector of the specified type for each LogicalType in the
3683
3685
  //! types list. The vector will be referencing vector to the data owned by
3684
3686
  //! the DataChunk.
3685
- void Initialize(const vector<LogicalType> &types);
3687
+ DUCKDB_API void Initialize(const vector<LogicalType> &types);
3686
3688
  //! Initializes an empty DataChunk with the given types. The vectors will *not* have any data allocated for them.
3687
- void InitializeEmpty(const vector<LogicalType> &types);
3689
+ DUCKDB_API void InitializeEmpty(const vector<LogicalType> &types);
3688
3690
  //! Append the other DataChunk to this one. The column count and types of
3689
3691
  //! the two DataChunks have to match exactly. Throws an exception if there
3690
3692
  //! is not enough space in the chunk and resize is not allowed.
@@ -5422,7 +5424,7 @@ public:
5422
5424
  }
5423
5425
 
5424
5426
  //! The location in the query (if any)
5425
- idx_t query_location = INVALID_INDEX;
5427
+ idx_t query_location = DConstants::INVALID_INDEX;
5426
5428
 
5427
5429
  public:
5428
5430
  bool IsAggregate() const override;
@@ -5491,11 +5493,8 @@ namespace duckdb {
5491
5493
  //! A column of a table.
5492
5494
  class ColumnDefinition {
5493
5495
  public:
5494
- ColumnDefinition(string name, LogicalType type) : name(name), type(type) {
5495
- }
5496
- ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression> default_value)
5497
- : name(name), type(type), default_value(move(default_value)) {
5498
- }
5496
+ DUCKDB_API ColumnDefinition(string name, LogicalType type);
5497
+ DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression> default_value);
5499
5498
 
5500
5499
  //! The name of the entry
5501
5500
  string name;
@@ -5509,10 +5508,10 @@ public:
5509
5508
  CompressionType compression_type = CompressionType::COMPRESSION_AUTO;
5510
5509
 
5511
5510
  public:
5512
- ColumnDefinition Copy() const;
5511
+ DUCKDB_API ColumnDefinition Copy() const;
5513
5512
 
5514
- void Serialize(Serializer &serializer) const;
5515
- static ColumnDefinition Deserialize(Deserializer &source);
5513
+ DUCKDB_API void Serialize(Serializer &serializer) const;
5514
+ DUCKDB_API static ColumnDefinition Deserialize(Deserializer &source);
5516
5515
  };
5517
5516
 
5518
5517
  } // namespace duckdb
@@ -5538,24 +5537,11 @@ class TableFunction;
5538
5537
  struct PragmaInfo;
5539
5538
 
5540
5539
  struct FunctionData {
5541
- virtual ~FunctionData() {
5542
- }
5540
+ DUCKDB_API virtual ~FunctionData();
5543
5541
 
5544
- virtual unique_ptr<FunctionData> Copy() {
5545
- throw InternalException("Unimplemented copy for FunctionData");
5546
- };
5547
- virtual bool Equals(FunctionData &other) {
5548
- return true;
5549
- }
5550
- static bool Equals(FunctionData *left, FunctionData *right) {
5551
- if (left == right) {
5552
- return true;
5553
- }
5554
- if (!left || !right) {
5555
- return false;
5556
- }
5557
- return left->Equals(*right);
5558
- }
5542
+ DUCKDB_API virtual unique_ptr<FunctionData> Copy();
5543
+ DUCKDB_API virtual bool Equals(FunctionData &other);
5544
+ DUCKDB_API static bool Equals(FunctionData *left, FunctionData *right);
5559
5545
  };
5560
5546
 
5561
5547
  struct TableFunctionData : public FunctionData {
@@ -5571,10 +5557,8 @@ struct FunctionParameters {
5571
5557
  //! Function is the base class used for any type of function (scalar, aggregate or simple function)
5572
5558
  class Function {
5573
5559
  public:
5574
- explicit Function(string name) : name(name) {
5575
- }
5576
- virtual ~Function() {
5577
- }
5560
+ DUCKDB_API explicit Function(string name);
5561
+ DUCKDB_API virtual ~Function();
5578
5562
 
5579
5563
  //! The name of the function
5580
5564
  string name;
@@ -5590,35 +5574,33 @@ public:
5590
5574
  const unordered_map<string, LogicalType> &named_parameters);
5591
5575
 
5592
5576
  //! Bind a scalar function from the set of functions and input arguments. Returns the index of the chosen function,
5593
- //! returns INVALID_INDEX and sets error if none could be found
5594
- static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions, vector<LogicalType> &arguments,
5595
- string &error);
5596
- static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5597
- vector<unique_ptr<Expression>> &arguments, string &error);
5577
+ //! returns DConstants::INVALID_INDEX and sets error if none could be found
5578
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5579
+ vector<LogicalType> &arguments, string &error);
5580
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5581
+ vector<unique_ptr<Expression>> &arguments, string &error);
5598
5582
  //! Bind an aggregate function from the set of functions and input arguments. Returns the index of the chosen
5599
- //! function, returns INVALID_INDEX and sets error if none could be found
5600
- static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions, vector<LogicalType> &arguments,
5601
- string &error);
5602
- static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5603
- vector<unique_ptr<Expression>> &arguments, string &error);
5583
+ //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
5584
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5585
+ vector<LogicalType> &arguments, string &error);
5586
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5587
+ vector<unique_ptr<Expression>> &arguments, string &error);
5604
5588
  //! Bind a table function from the set of functions and input arguments. Returns the index of the chosen
5605
- //! function, returns INVALID_INDEX and sets error if none could be found
5606
- static idx_t BindFunction(const string &name, vector<TableFunction> &functions, vector<LogicalType> &arguments,
5607
- string &error);
5608
- static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5609
- vector<unique_ptr<Expression>> &arguments, string &error);
5589
+ //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
5590
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5591
+ vector<LogicalType> &arguments, string &error);
5592
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5593
+ vector<unique_ptr<Expression>> &arguments, string &error);
5610
5594
  //! Bind a pragma function from the set of functions and input arguments
5611
- static idx_t BindFunction(const string &name, vector<PragmaFunction> &functions, PragmaInfo &info, string &error);
5595
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<PragmaFunction> &functions, PragmaInfo &info,
5596
+ string &error);
5612
5597
  };
5613
5598
 
5614
5599
  class SimpleFunction : public Function {
5615
5600
  public:
5616
- SimpleFunction(string name, vector<LogicalType> arguments,
5617
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
5618
- : Function(name), arguments(move(arguments)), varargs(varargs) {
5619
- }
5620
- ~SimpleFunction() override {
5621
- }
5601
+ DUCKDB_API SimpleFunction(string name, vector<LogicalType> arguments,
5602
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5603
+ DUCKDB_API ~SimpleFunction() override;
5622
5604
 
5623
5605
  //! The set of arguments of the function
5624
5606
  vector<LogicalType> arguments;
@@ -5627,50 +5609,34 @@ public:
5627
5609
  LogicalType varargs;
5628
5610
 
5629
5611
  public:
5630
- virtual string ToString() {
5631
- return Function::CallToString(name, arguments);
5632
- }
5612
+ DUCKDB_API virtual string ToString();
5633
5613
 
5634
- bool HasVarArgs() const {
5635
- return varargs.id() != LogicalTypeId::INVALID;
5636
- }
5614
+ DUCKDB_API bool HasVarArgs() const;
5637
5615
  };
5638
5616
 
5639
5617
  class SimpleNamedParameterFunction : public SimpleFunction {
5640
5618
  public:
5641
- SimpleNamedParameterFunction(string name, vector<LogicalType> arguments,
5642
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
5643
- : SimpleFunction(name, move(arguments), varargs) {
5644
- }
5645
- ~SimpleNamedParameterFunction() override {
5646
- }
5619
+ DUCKDB_API SimpleNamedParameterFunction(string name, vector<LogicalType> arguments,
5620
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5621
+ DUCKDB_API ~SimpleNamedParameterFunction() override;
5647
5622
 
5648
5623
  //! The named parameters of the function
5649
5624
  unordered_map<string, LogicalType> named_parameters;
5650
5625
 
5651
5626
  public:
5652
- string ToString() override {
5653
- return Function::CallToString(name, arguments, named_parameters);
5654
- }
5655
-
5656
- bool HasNamedParameters() {
5657
- return named_parameters.size() != 0;
5658
- }
5627
+ DUCKDB_API string ToString() override;
5628
+ DUCKDB_API bool HasNamedParameters();
5659
5629
 
5660
- void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5661
- unordered_map<string, Value> &named_parameters,
5662
- vector<unique_ptr<ParsedExpression>> &children);
5630
+ DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5631
+ unordered_map<string, Value> &named_parameters,
5632
+ vector<unique_ptr<ParsedExpression>> &children);
5663
5633
  };
5664
5634
 
5665
5635
  class BaseScalarFunction : public SimpleFunction {
5666
5636
  public:
5667
- BaseScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type, bool has_side_effects,
5668
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
5669
- : SimpleFunction(move(name), move(arguments), move(varargs)), return_type(return_type),
5670
- has_side_effects(has_side_effects) {
5671
- }
5672
- ~BaseScalarFunction() override {
5673
- }
5637
+ DUCKDB_API BaseScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
5638
+ bool has_side_effects, LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5639
+ DUCKDB_API ~BaseScalarFunction() override;
5674
5640
 
5675
5641
  //! Return type of the function
5676
5642
  LogicalType return_type;
@@ -5679,14 +5645,12 @@ public:
5679
5645
  bool has_side_effects;
5680
5646
 
5681
5647
  public:
5682
- hash_t Hash() const;
5648
+ DUCKDB_API hash_t Hash() const;
5683
5649
 
5684
5650
  //! Cast a set of expressions to the arguments of this function
5685
- void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
5651
+ DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
5686
5652
 
5687
- string ToString() override {
5688
- return Function::CallToString(name, arguments, return_type);
5689
- }
5653
+ DUCKDB_API string ToString() override;
5690
5654
  };
5691
5655
 
5692
5656
  class BuiltinFunctions {
@@ -6408,23 +6372,17 @@ typedef void (*dependency_function_t)(BoundFunctionExpression &expr, unordered_s
6408
6372
 
6409
6373
  class ScalarFunction : public BaseScalarFunction {
6410
6374
  public:
6411
- ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6412
- bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6413
- dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6414
- init_local_state_t init_local_state = nullptr,
6415
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
6416
- : BaseScalarFunction(name, arguments, return_type, has_side_effects, varargs), function(function), bind(bind),
6417
- init_local_state(init_local_state), dependency(dependency), statistics(statistics) {
6418
- }
6375
+ DUCKDB_API ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
6376
+ scalar_function_t function, bool has_side_effects = false,
6377
+ bind_scalar_function_t bind = nullptr, dependency_function_t dependency = nullptr,
6378
+ function_statistics_t statistics = nullptr, init_local_state_t init_local_state = nullptr,
6379
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
6419
6380
 
6420
- ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6421
- bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6422
- dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6423
- init_local_state_t init_local_state = nullptr,
6424
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
6425
- : ScalarFunction(string(), arguments, return_type, function, has_side_effects, bind, dependency, statistics,
6426
- init_local_state, varargs) {
6427
- }
6381
+ DUCKDB_API ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6382
+ bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6383
+ dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6384
+ init_local_state_t init_local_state = nullptr,
6385
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
6428
6386
 
6429
6387
  //! The main scalar function to execute
6430
6388
  scalar_function_t function;
@@ -6437,73 +6395,30 @@ public:
6437
6395
  //! The statistics propagation function (if any)
6438
6396
  function_statistics_t statistics;
6439
6397
 
6440
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context, const string &schema,
6441
- const string &name,
6442
- vector<unique_ptr<Expression>> children,
6443
- string &error, bool is_operator = false);
6444
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6445
- ScalarFunctionCatalogEntry &function,
6446
- vector<unique_ptr<Expression>> children,
6447
- string &error, bool is_operator = false);
6398
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6399
+ const string &schema, const string &name,
6400
+ vector<unique_ptr<Expression>> children,
6401
+ string &error, bool is_operator = false);
6402
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6403
+ ScalarFunctionCatalogEntry &function,
6404
+ vector<unique_ptr<Expression>> children,
6405
+ string &error, bool is_operator = false);
6448
6406
 
6449
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context, ScalarFunction bound_function,
6450
- vector<unique_ptr<Expression>> children,
6451
- bool is_operator = false);
6407
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6408
+ ScalarFunction bound_function,
6409
+ vector<unique_ptr<Expression>> children,
6410
+ bool is_operator = false);
6452
6411
 
6453
- bool operator==(const ScalarFunction &rhs) const {
6454
- return CompareScalarFunctionT(rhs.function) && bind == rhs.bind && dependency == rhs.dependency &&
6455
- statistics == rhs.statistics;
6456
- }
6457
- bool operator!=(const ScalarFunction &rhs) const {
6458
- return !(*this == rhs);
6459
- }
6412
+ DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
6413
+ DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
6460
6414
 
6461
- bool Equal(const ScalarFunction &rhs) const {
6462
- // number of types
6463
- if (this->arguments.size() != rhs.arguments.size()) {
6464
- return false;
6465
- }
6466
- // argument types
6467
- for (idx_t i = 0; i < this->arguments.size(); ++i) {
6468
- if (this->arguments[i] != rhs.arguments[i]) {
6469
- return false;
6470
- }
6471
- }
6472
- // return type
6473
- if (this->return_type != rhs.return_type) {
6474
- return false;
6475
- }
6476
- // varargs
6477
- if (this->varargs != rhs.varargs) {
6478
- return false;
6479
- }
6480
-
6481
- return true; // they are equal
6482
- }
6415
+ DUCKDB_API bool Equal(const ScalarFunction &rhs) const;
6483
6416
 
6484
6417
  private:
6485
- bool CompareScalarFunctionT(const scalar_function_t other) const {
6486
- typedef void(scalar_function_ptr_t)(DataChunk &, ExpressionState &, Vector &);
6487
-
6488
- auto func_ptr = (scalar_function_ptr_t **)function.template target<scalar_function_ptr_t *>();
6489
- auto other_ptr = (scalar_function_ptr_t **)other.template target<scalar_function_ptr_t *>();
6490
-
6491
- // Case the functions were created from lambdas the target will return a nullptr
6492
- if (!func_ptr && !other_ptr) {
6493
- return true;
6494
- }
6495
- if (func_ptr == nullptr || other_ptr == nullptr) {
6496
- // scalar_function_t (std::functions) from lambdas cannot be compared
6497
- return false;
6498
- }
6499
- return ((size_t)*func_ptr == (size_t)*other_ptr);
6500
- }
6418
+ bool CompareScalarFunctionT(const scalar_function_t &other) const;
6501
6419
 
6502
6420
  public:
6503
- static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result) {
6504
- D_ASSERT(input.ColumnCount() >= 1);
6505
- result.Reference(input.data[0]);
6506
- }
6421
+ DUCKDB_API static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result);
6507
6422
 
6508
6423
  template <class TA, class TR, class OP>
6509
6424
  static void UnaryFunction(DataChunk &input, ExpressionState &state, Vector &result) {
@@ -6954,12 +6869,12 @@ public:
6954
6869
 
6955
6870
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
6956
6871
  static void UnaryWindow(Vector &input, FunctionData *bind_data, data_ptr_t state, const FrameBounds &frame,
6957
- const FrameBounds &prev, Vector &result, idx_t rid) {
6872
+ const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
6958
6873
 
6959
- auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - MinValue(frame.first, prev.first);
6874
+ auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
6960
6875
  const auto &ivalid = FlatVector::Validity(input);
6961
6876
  OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ivalid, bind_data, (STATE *)state, frame, prev,
6962
- result, rid);
6877
+ result, rid, bias);
6963
6878
  }
6964
6879
 
6965
6880
  template <class STATE_TYPE, class OP>
@@ -7343,7 +7258,7 @@ class SQLStatement;
7343
7258
 
7344
7259
  class QueryErrorContext {
7345
7260
  public:
7346
- explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = INVALID_INDEX)
7261
+ explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = DConstants::INVALID_INDEX)
7347
7262
  : statement(statement_), query_location(query_location_) {
7348
7263
  }
7349
7264
 
@@ -7388,6 +7303,7 @@ struct CreateViewInfo;
7388
7303
  struct CreateSequenceInfo;
7389
7304
  struct CreateCollationInfo;
7390
7305
  struct CreateTypeInfo;
7306
+ struct CreateTableInfo;
7391
7307
 
7392
7308
  class ClientContext;
7393
7309
  class Transaction;
@@ -7410,7 +7326,7 @@ struct CatalogEntryLookup {
7410
7326
  SchemaCatalogEntry *schema;
7411
7327
  CatalogEntry *entry;
7412
7328
 
7413
- bool Found() const {
7329
+ DUCKDB_API bool Found() const {
7414
7330
  return entry;
7415
7331
  }
7416
7332
  };
@@ -7424,11 +7340,11 @@ struct SimilarCatalogEntry {
7424
7340
  //! The schema of the entry.
7425
7341
  SchemaCatalogEntry *schema;
7426
7342
 
7427
- bool Found() const {
7343
+ DUCKDB_API bool Found() const {
7428
7344
  return !name.empty();
7429
7345
  }
7430
7346
 
7431
- string GetQualifiedName() const;
7347
+ DUCKDB_API string GetQualifiedName() const;
7432
7348
  };
7433
7349
 
7434
7350
  //! The Catalog object represents the catalog of the database.
@@ -7448,79 +7364,88 @@ public:
7448
7364
 
7449
7365
  public:
7450
7366
  //! Get the ClientContext from the Catalog
7451
- static Catalog &GetCatalog(ClientContext &context);
7452
- static Catalog &GetCatalog(DatabaseInstance &db);
7367
+ DUCKDB_API static Catalog &GetCatalog(ClientContext &context);
7368
+ DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db);
7453
7369
 
7454
- DependencyManager &GetDependencyManager() {
7370
+ DUCKDB_API DependencyManager &GetDependencyManager() {
7455
7371
  return *dependency_manager;
7456
7372
  }
7457
7373
 
7458
7374
  //! Returns the current version of the catalog (incremented whenever anything changes, not stored between restarts)
7459
- idx_t GetCatalogVersion();
7375
+ DUCKDB_API idx_t GetCatalogVersion();
7460
7376
  //! Trigger a modification in the catalog, increasing the catalog version and returning the previous version
7461
- idx_t ModifyCatalog();
7377
+ DUCKDB_API idx_t ModifyCatalog();
7462
7378
 
7463
7379
  //! Creates a schema in the catalog.
7464
- CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
7380
+ DUCKDB_API CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
7465
7381
  //! Creates a table in the catalog.
7466
- CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
7382
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
7383
+ //! Creates a table in the catalog.
7384
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, unique_ptr<CreateTableInfo> info);
7467
7385
  //! Create a table function in the catalog
7468
- CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
7386
+ DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
7469
7387
  //! Create a copy function in the catalog
7470
- CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
7388
+ DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
7471
7389
  //! Create a pragma function in the catalog
7472
- CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
7390
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
7473
7391
  //! Create a scalar or aggregate function in the catalog
7474
- CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
7392
+ DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
7475
7393
  //! Creates a table in the catalog.
7476
- CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
7394
+ DUCKDB_API CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
7477
7395
  //! Creates a table in the catalog.
7478
- CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
7396
+ DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
7479
7397
  //! Creates a Enum in the catalog.
7480
- CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
7398
+ DUCKDB_API CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
7481
7399
  //! Creates a collation in the catalog
7482
- CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
7400
+ DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
7483
7401
 
7484
7402
  //! Creates a table in the catalog.
7485
- CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema, BoundCreateTableInfo *info);
7403
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema,
7404
+ BoundCreateTableInfo *info);
7486
7405
  //! Create a table function in the catalog
7487
- CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
7488
- CreateTableFunctionInfo *info);
7406
+ DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
7407
+ CreateTableFunctionInfo *info);
7489
7408
  //! Create a copy function in the catalog
7490
- CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateCopyFunctionInfo *info);
7409
+ DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema,
7410
+ CreateCopyFunctionInfo *info);
7491
7411
  //! Create a pragma function in the catalog
7492
- CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
7493
- CreatePragmaFunctionInfo *info);
7412
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
7413
+ CreatePragmaFunctionInfo *info);
7494
7414
  //! Create a scalar or aggregate function in the catalog
7495
- CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info);
7415
+ DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema,
7416
+ CreateFunctionInfo *info);
7496
7417
  //! Creates a table in the catalog.
7497
- CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
7418
+ DUCKDB_API CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
7498
7419
  //! Creates a table in the catalog.
7499
- CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema, CreateSequenceInfo *info);
7420
+ DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema,
7421
+ CreateSequenceInfo *info);
7500
7422
  //! Creates a enum in the catalog.
7501
- CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
7423
+ DUCKDB_API CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
7502
7424
  //! Creates a collation in the catalog
7503
- CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema, CreateCollationInfo *info);
7425
+ DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema,
7426
+ CreateCollationInfo *info);
7504
7427
 
7505
7428
  //! Drops an entry from the catalog
7506
- void DropEntry(ClientContext &context, DropInfo *info);
7429
+ DUCKDB_API void DropEntry(ClientContext &context, DropInfo *info);
7507
7430
 
7508
7431
  //! Returns the schema object with the specified name, or throws an exception if it does not exist
7509
- SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA, bool if_exists = false,
7510
- QueryErrorContext error_context = QueryErrorContext());
7432
+ DUCKDB_API SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA,
7433
+ bool if_exists = false,
7434
+ QueryErrorContext error_context = QueryErrorContext());
7511
7435
  //! Scans all the schemas in the system one-by-one, invoking the callback for each entry
7512
- void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
7436
+ DUCKDB_API void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
7513
7437
  //! Gets the "schema.name" entry of the specified type, if if_exists=true returns nullptr if entry does not exist,
7514
7438
  //! otherwise an exception is thrown
7515
- CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema, const string &name,
7516
- bool if_exists = false, QueryErrorContext error_context = QueryErrorContext());
7439
+ DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema,
7440
+ const string &name, bool if_exists = false,
7441
+ QueryErrorContext error_context = QueryErrorContext());
7517
7442
 
7518
7443
  template <class T>
7519
7444
  T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
7520
7445
  QueryErrorContext error_context = QueryErrorContext());
7521
7446
 
7522
7447
  //! Alter an existing entry in the catalog.
7523
- void Alter(ClientContext &context, AlterInfo *info);
7448
+ DUCKDB_API void Alter(ClientContext &context, AlterInfo *info);
7524
7449
 
7525
7450
  private:
7526
7451
  //! The catalog version, incremented whenever anything changes in the catalog
@@ -7544,26 +7469,30 @@ private:
7544
7469
  };
7545
7470
 
7546
7471
  template <>
7547
- TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7548
- bool if_exists, QueryErrorContext error_context);
7472
+ DUCKDB_API TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7473
+ bool if_exists, QueryErrorContext error_context);
7549
7474
  template <>
7550
- SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7551
- bool if_exists, QueryErrorContext error_context);
7475
+ DUCKDB_API SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7476
+ const string &name, bool if_exists, QueryErrorContext error_context);
7552
7477
  template <>
7553
- TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7554
- bool if_exists, QueryErrorContext error_context);
7478
+ DUCKDB_API TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7479
+ const string &name, bool if_exists,
7480
+ QueryErrorContext error_context);
7555
7481
  template <>
7556
- CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7557
- bool if_exists, QueryErrorContext error_context);
7482
+ DUCKDB_API CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7483
+ const string &name, bool if_exists,
7484
+ QueryErrorContext error_context);
7558
7485
  template <>
7559
- PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7560
- bool if_exists, QueryErrorContext error_context);
7486
+ DUCKDB_API PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7487
+ const string &name, bool if_exists,
7488
+ QueryErrorContext error_context);
7561
7489
  template <>
7562
- AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7563
- bool if_exists, QueryErrorContext error_context);
7490
+ DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7491
+ const string &name, bool if_exists,
7492
+ QueryErrorContext error_context);
7564
7493
  template <>
7565
- CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7566
- bool if_exists, QueryErrorContext error_context);
7494
+ DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7495
+ bool if_exists, QueryErrorContext error_context);
7567
7496
 
7568
7497
  } // namespace duckdb
7569
7498
 
@@ -7928,7 +7857,7 @@ struct ColumnBinding {
7928
7857
  idx_t table_index;
7929
7858
  idx_t column_index;
7930
7859
 
7931
- ColumnBinding() : table_index(INVALID_INDEX), column_index(INVALID_INDEX) {
7860
+ ColumnBinding() : table_index(DConstants::INVALID_INDEX), column_index(DConstants::INVALID_INDEX) {
7932
7861
  }
7933
7862
  ColumnBinding(idx_t table, idx_t column) : table_index(table), column_index(column) {
7934
7863
  }
@@ -7982,7 +7911,7 @@ public:
7982
7911
 
7983
7912
  virtual string GetName() const;
7984
7913
  virtual string ParamsToString() const;
7985
- virtual string ToString(idx_t depth = 0) const;
7914
+ virtual string ToString() const;
7986
7915
  void Print();
7987
7916
  //! Debug method: verify that the integrity of expressions & child nodes are maintained
7988
7917
  virtual void Verify();
@@ -8126,26 +8055,29 @@ typedef void (*aggregate_simple_update_t)(Vector inputs[], FunctionData *bind_da
8126
8055
  //! The type used for updating complex windowed aggregate functions (optional)
8127
8056
  typedef std::pair<idx_t, idx_t> FrameBounds;
8128
8057
  typedef void (*aggregate_window_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
8129
- const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t offset);
8058
+ const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid,
8059
+ idx_t bias);
8130
8060
 
8131
8061
  class AggregateFunction : public BaseScalarFunction {
8132
8062
  public:
8133
- AggregateFunction(const string &name, const vector<LogicalType> &arguments, const LogicalType &return_type,
8134
- aggregate_size_t state_size, aggregate_initialize_t initialize, aggregate_update_t update,
8135
- aggregate_combine_t combine, aggregate_finalize_t finalize,
8136
- aggregate_simple_update_t simple_update = nullptr, bind_aggregate_function_t bind = nullptr,
8137
- aggregate_destructor_t destructor = nullptr, aggregate_statistics_t statistics = nullptr,
8138
- aggregate_window_t window = nullptr)
8063
+ DUCKDB_API AggregateFunction(const string &name, const vector<LogicalType> &arguments,
8064
+ const LogicalType &return_type, aggregate_size_t state_size,
8065
+ aggregate_initialize_t initialize, aggregate_update_t update,
8066
+ aggregate_combine_t combine, aggregate_finalize_t finalize,
8067
+ aggregate_simple_update_t simple_update = nullptr,
8068
+ bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8069
+ aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8139
8070
  : BaseScalarFunction(name, arguments, return_type, false), state_size(state_size), initialize(initialize),
8140
8071
  update(update), combine(combine), finalize(finalize), simple_update(simple_update), window(window),
8141
8072
  bind(bind), destructor(destructor), statistics(statistics) {
8142
8073
  }
8143
8074
 
8144
- AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type, aggregate_size_t state_size,
8145
- aggregate_initialize_t initialize, aggregate_update_t update, aggregate_combine_t combine,
8146
- aggregate_finalize_t finalize, aggregate_simple_update_t simple_update = nullptr,
8147
- bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8148
- aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8075
+ DUCKDB_API AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type,
8076
+ aggregate_size_t state_size, aggregate_initialize_t initialize,
8077
+ aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize,
8078
+ aggregate_simple_update_t simple_update = nullptr,
8079
+ bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8080
+ aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8149
8081
  : AggregateFunction(string(), arguments, return_type, state_size, initialize, update, combine, finalize,
8150
8082
  simple_update, bind, destructor, statistics, window) {
8151
8083
  }
@@ -8173,23 +8105,23 @@ public:
8173
8105
  //! The statistics propagation function (may be null)
8174
8106
  aggregate_statistics_t statistics;
8175
8107
 
8176
- bool operator==(const AggregateFunction &rhs) const {
8108
+ DUCKDB_API bool operator==(const AggregateFunction &rhs) const {
8177
8109
  return state_size == rhs.state_size && initialize == rhs.initialize && update == rhs.update &&
8178
8110
  combine == rhs.combine && finalize == rhs.finalize && window == rhs.window;
8179
8111
  }
8180
- bool operator!=(const AggregateFunction &rhs) const {
8112
+ DUCKDB_API bool operator!=(const AggregateFunction &rhs) const {
8181
8113
  return !(*this == rhs);
8182
8114
  }
8183
8115
 
8184
- static unique_ptr<BoundAggregateExpression>
8116
+ DUCKDB_API static unique_ptr<BoundAggregateExpression>
8185
8117
  BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
8186
8118
  vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
8187
8119
  bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr);
8188
8120
 
8189
- static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
8190
- vector<unique_ptr<Expression>> &children,
8191
- unique_ptr<FunctionData> bind_info,
8192
- unique_ptr<BoundOrderModifier> order_bys);
8121
+ DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
8122
+ vector<unique_ptr<Expression>> &children,
8123
+ unique_ptr<FunctionData> bind_info,
8124
+ unique_ptr<BoundOrderModifier> order_bys);
8193
8125
 
8194
8126
  public:
8195
8127
  template <class STATE, class RESULT_TYPE, class OP>
@@ -8268,10 +8200,10 @@ public:
8268
8200
 
8269
8201
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
8270
8202
  static void UnaryWindow(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
8271
- const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid) {
8203
+ const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
8272
8204
  D_ASSERT(input_count == 1);
8273
8205
  AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], bind_data, state, frame, prev,
8274
- result, rid);
8206
+ result, rid, bias);
8275
8207
  }
8276
8208
 
8277
8209
  template <class STATE, class A_TYPE, class B_TYPE, class OP>
@@ -9464,11 +9396,13 @@ namespace duckdb {
9464
9396
  class Printer {
9465
9397
  public:
9466
9398
  //! Print the object to stderr
9467
- static void Print(const string &str);
9399
+ DUCKDB_API static void Print(const string &str);
9468
9400
  //! Prints Progress
9469
- static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9401
+ DUCKDB_API static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9470
9402
  //! Prints an empty line when progress bar is done
9471
- static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9403
+ DUCKDB_API static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9404
+ //! Whether or not we are printing to a terminal
9405
+ DUCKDB_API static bool IsTerminal();
9472
9406
  };
9473
9407
  } // namespace duckdb
9474
9408
 
@@ -9830,16 +9764,16 @@ namespace duckdb {
9830
9764
  */
9831
9765
  class StringUtil {
9832
9766
  public:
9833
- static bool CharacterIsSpace(char c) {
9767
+ DUCKDB_API static bool CharacterIsSpace(char c) {
9834
9768
  return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
9835
9769
  }
9836
- static bool CharacterIsNewline(char c) {
9770
+ DUCKDB_API static bool CharacterIsNewline(char c) {
9837
9771
  return c == '\n' || c == '\r';
9838
9772
  }
9839
- static bool CharacterIsDigit(char c) {
9773
+ DUCKDB_API static bool CharacterIsDigit(char c) {
9840
9774
  return c >= '0' && c <= '9';
9841
9775
  }
9842
- static char CharacterToLower(char c) {
9776
+ DUCKDB_API static char CharacterToLower(char c) {
9843
9777
  if (c >= 'A' && c <= 'Z') {
9844
9778
  return c - ('A' - 'a');
9845
9779
  }
@@ -9847,25 +9781,25 @@ public:
9847
9781
  }
9848
9782
 
9849
9783
  //! Returns true if the needle string exists in the haystack
9850
- static bool Contains(const string &haystack, const string &needle);
9784
+ DUCKDB_API static bool Contains(const string &haystack, const string &needle);
9851
9785
 
9852
9786
  //! Returns true if the target string starts with the given prefix
9853
- static bool StartsWith(string str, string prefix);
9787
+ DUCKDB_API static bool StartsWith(string str, string prefix);
9854
9788
 
9855
9789
  //! Returns true if the target string <b>ends</b> with the given suffix.
9856
- static bool EndsWith(const string &str, const string &suffix);
9790
+ DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
9857
9791
 
9858
9792
  //! Repeat a string multiple times
9859
- static string Repeat(const string &str, const idx_t n);
9793
+ DUCKDB_API static string Repeat(const string &str, const idx_t n);
9860
9794
 
9861
9795
  //! Split the input string based on newline char
9862
- static vector<string> Split(const string &str, char delimiter);
9796
+ DUCKDB_API static vector<string> Split(const string &str, char delimiter);
9863
9797
 
9864
9798
  //! Split the input string allong a quote. Note that any escaping is NOT supported.
9865
- static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
9799
+ DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
9866
9800
 
9867
9801
  //! Join multiple strings into one string. Components are concatenated by the given separator
9868
- static string Join(const vector<string> &input, const string &separator);
9802
+ DUCKDB_API static string Join(const vector<string> &input, const string &separator);
9869
9803
 
9870
9804
  //! Join multiple items of container with given size, transformed to string
9871
9805
  //! using function, into one string using the given separator
@@ -9889,13 +9823,13 @@ public:
9889
9823
  }
9890
9824
 
9891
9825
  //! Return a string that formats the give number of bytes
9892
- static string BytesToHumanReadableString(idx_t bytes);
9826
+ DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
9893
9827
 
9894
9828
  //! Convert a string to uppercase
9895
- static string Upper(const string &str);
9829
+ DUCKDB_API static string Upper(const string &str);
9896
9830
 
9897
9831
  //! Convert a string to lowercase
9898
- static string Lower(const string &str);
9832
+ DUCKDB_API static string Lower(const string &str);
9899
9833
 
9900
9834
  //! Format a string using printf semantics
9901
9835
  template <typename... Args>
@@ -9904,30 +9838,38 @@ public:
9904
9838
  }
9905
9839
 
9906
9840
  //! Split the input string into a vector of strings based on the split string
9907
- static vector<string> Split(const string &input, const string &split);
9841
+ DUCKDB_API static vector<string> Split(const string &input, const string &split);
9908
9842
 
9909
9843
  //! Remove the whitespace char in the left end of the string
9910
- static void LTrim(string &str);
9844
+ DUCKDB_API static void LTrim(string &str);
9911
9845
  //! Remove the whitespace char in the right end of the string
9912
- static void RTrim(string &str);
9846
+ DUCKDB_API static void RTrim(string &str);
9913
9847
  //! Remove the whitespace char in the left and right end of the string
9914
- static void Trim(string &str);
9848
+ DUCKDB_API static void Trim(string &str);
9915
9849
 
9916
- static string Replace(string source, const string &from, const string &to);
9850
+ DUCKDB_API static string Replace(string source, const string &from, const string &to);
9917
9851
 
9918
9852
  //! Get the levenshtein distance from two strings
9919
- static idx_t LevenshteinDistance(const string &s1, const string &s2);
9853
+ DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
9920
9854
 
9921
9855
  //! Get the top-n strings (sorted by the given score distance) from a set of scores.
9922
9856
  //! At least one entry is returned (if there is one).
9923
9857
  //! Strings are only returned if they have a score less than the threshold.
9924
- static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5, idx_t threshold = 5);
9858
+ DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
9859
+ idx_t threshold = 5);
9925
9860
  //! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
9926
9861
  //! with the given params.
9927
- static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
9928
- idx_t threshold = 5);
9929
- static string CandidatesMessage(const vector<string> &candidates, const string &candidate = "Candidate bindings");
9862
+ DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
9863
+ idx_t threshold = 5);
9864
+ DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
9865
+ const string &candidate = "Candidate bindings");
9866
+
9867
+ //! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
9868
+ //! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
9869
+ DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
9870
+ const string &message_prefix, idx_t n = 5);
9930
9871
  };
9872
+
9931
9873
  } // namespace duckdb
9932
9874
 
9933
9875
 
@@ -10040,6 +9982,7 @@ enum class OptimizerType : uint32_t {
10040
9982
  };
10041
9983
 
10042
9984
  string OptimizerTypeToString(OptimizerType type);
9985
+ OptimizerType OptimizerTypeFromString(const string &str);
10043
9986
 
10044
9987
  } // namespace duckdb
10045
9988
 
@@ -10068,6 +10011,29 @@ enum class WindowAggregationMode : uint32_t {
10068
10011
 
10069
10012
  } // namespace duckdb
10070
10013
 
10014
+ //===----------------------------------------------------------------------===//
10015
+ // DuckDB
10016
+ //
10017
+ // duckdb/common/enums/set_scope.hpp
10018
+ //
10019
+ //
10020
+ //===----------------------------------------------------------------------===//
10021
+
10022
+
10023
+
10024
+
10025
+
10026
+ namespace duckdb {
10027
+
10028
+ enum class SetScope : uint8_t {
10029
+ AUTOMATIC = 0,
10030
+ LOCAL = 1, /* unused */
10031
+ SESSION = 2,
10032
+ GLOBAL = 3
10033
+ };
10034
+
10035
+ } // namespace duckdb
10036
+
10071
10037
 
10072
10038
  namespace duckdb {
10073
10039
  class ClientContext;
@@ -10075,6 +10041,7 @@ class TableFunctionRef;
10075
10041
  class CompressionFunction;
10076
10042
 
10077
10043
  struct CompressionFunctionSet;
10044
+ struct DBConfig;
10078
10045
 
10079
10046
  enum class AccessMode : uint8_t { UNDEFINED = 0, AUTOMATIC = 1, READ_ONLY = 2, READ_WRITE = 3 };
10080
10047
 
@@ -10085,25 +10052,31 @@ enum class CheckpointAbort : uint8_t {
10085
10052
  DEBUG_ABORT_AFTER_FREE_LIST_WRITE = 3
10086
10053
  };
10087
10054
 
10088
- enum class ConfigurationOptionType : uint32_t {
10089
- INVALID = 0,
10090
- ACCESS_MODE,
10091
- DEFAULT_ORDER_TYPE,
10092
- DEFAULT_NULL_ORDER,
10093
- ENABLE_EXTERNAL_ACCESS,
10094
- ENABLE_OBJECT_CACHE,
10095
- MAXIMUM_MEMORY,
10096
- THREADS
10097
- };
10055
+ typedef void (*set_global_function_t)(DatabaseInstance *db, DBConfig &config, const Value &parameter);
10056
+ typedef void (*set_local_function_t)(ClientContext &context, const Value &parameter);
10057
+ typedef Value (*get_setting_function_t)(ClientContext &context);
10098
10058
 
10099
10059
  struct ConfigurationOption {
10100
- ConfigurationOptionType type;
10101
10060
  const char *name;
10102
10061
  const char *description;
10103
10062
  LogicalTypeId parameter_type;
10063
+ set_global_function_t set_global;
10064
+ set_local_function_t set_local;
10065
+ get_setting_function_t get_setting;
10066
+ };
10067
+
10068
+ typedef void (*set_option_callback_t)(ClientContext &context, SetScope scope, Value &parameter);
10069
+
10070
+ struct ExtensionOption {
10071
+ ExtensionOption(string description_p, LogicalType type_p, set_option_callback_t set_function_p)
10072
+ : description(move(description_p)), type(move(type_p)), set_function(set_function_p) {
10073
+ }
10074
+
10075
+ string description;
10076
+ LogicalType type;
10077
+ set_option_callback_t set_function;
10104
10078
  };
10105
10079
 
10106
- // this is optional and only used in tests at the moment
10107
10080
  struct DBConfig {
10108
10081
  friend class DatabaseInstance;
10109
10082
  friend class StorageManager;
@@ -10143,8 +10116,6 @@ public:
10143
10116
  bool enable_external_access = true;
10144
10117
  //! Whether or not object cache is used
10145
10118
  bool object_cache_enable = false;
10146
- //! Database configuration variables as controlled by SET
10147
- case_insensitive_map_t<Value> set_variables;
10148
10119
  //! Force checkpoint when CHECKPOINT is called or on shutdown, even if no changes have been made
10149
10120
  bool force_checkpoint = false;
10150
10121
  //! Run a checkpoint on successful shutdown and delete the WAL, to leave only a single database file behind
@@ -10165,6 +10136,14 @@ public:
10165
10136
  //! Debug setting for window aggregation mode: (window, combine, separate)
10166
10137
  WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
10167
10138
 
10139
+ //! Extra parameters that can be SET for loaded extensions
10140
+ case_insensitive_map_t<ExtensionOption> extension_parameters;
10141
+ //! Database configuration variables as controlled by SET
10142
+ case_insensitive_map_t<Value> set_variables;
10143
+
10144
+ DUCKDB_API void AddExtensionOption(string name, string description, LogicalType parameter,
10145
+ set_option_callback_t function = nullptr);
10146
+
10168
10147
  public:
10169
10148
  DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
10170
10149
  DUCKDB_API static DBConfig &GetConfig(DatabaseInstance &db);
@@ -10210,8 +10189,10 @@ class DuckDB;
10210
10189
  //! The Extension class is the base class used to define extensions
10211
10190
  class Extension {
10212
10191
  public:
10192
+ DUCKDB_API virtual ~Extension();
10193
+
10213
10194
  DUCKDB_API virtual void Load(DuckDB &db) = 0;
10214
- DUCKDB_API virtual ~Extension() = default;
10195
+ DUCKDB_API virtual std::string Name() = 0;
10215
10196
  };
10216
10197
 
10217
10198
  } // namespace duckdb
@@ -10259,6 +10240,7 @@ private:
10259
10240
  unique_ptr<TaskScheduler> scheduler;
10260
10241
  unique_ptr<ObjectCache> object_cache;
10261
10242
  unique_ptr<ConnectionManager> connection_manager;
10243
+ unordered_set<std::string> loaded_extensions;
10262
10244
  };
10263
10245
 
10264
10246
  //! The database object. This object holds the catalog and all the
@@ -10267,6 +10249,8 @@ class DuckDB {
10267
10249
  public:
10268
10250
  DUCKDB_API explicit DuckDB(const char *path = nullptr, DBConfig *config = nullptr);
10269
10251
  DUCKDB_API explicit DuckDB(const string &path, DBConfig *config = nullptr);
10252
+ DUCKDB_API explicit DuckDB(DatabaseInstance &instance);
10253
+
10270
10254
  DUCKDB_API ~DuckDB();
10271
10255
 
10272
10256
  //! Reference to the actual database instance
@@ -10276,7 +10260,11 @@ public:
10276
10260
  template <class T>
10277
10261
  void LoadExtension() {
10278
10262
  T extension;
10263
+ if (ExtensionIsLoaded(extension.Name())) {
10264
+ return;
10265
+ }
10279
10266
  extension.Load(*this);
10267
+ SetExtensionLoaded(extension.Name());
10280
10268
  }
10281
10269
 
10282
10270
  DUCKDB_API FileSystem &GetFileSystem();
@@ -10284,16 +10272,39 @@ public:
10284
10272
  DUCKDB_API idx_t NumberOfThreads();
10285
10273
  DUCKDB_API static const char *SourceID();
10286
10274
  DUCKDB_API static const char *LibraryVersion();
10275
+ DUCKDB_API static string Platform();
10276
+ DUCKDB_API bool ExtensionIsLoaded(const std::string &name);
10277
+ DUCKDB_API void SetExtensionLoaded(const std::string &name);
10287
10278
  };
10288
10279
 
10289
10280
  } // namespace duckdb
10290
10281
 
10291
10282
 
10283
+ //===----------------------------------------------------------------------===//
10284
+ // DuckDB
10285
+ //
10286
+ // duckdb/main/loadable_extension.hpp
10287
+ //
10288
+ //
10289
+ //===----------------------------------------------------------------------===//
10290
+
10292
10291
 
10293
10292
 
10294
10293
  #ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
10295
10294
  #ifdef _WIN32
10295
+ #ifndef NOMINMAX
10296
+ #define NOMINMAX
10297
+ #endif
10298
+
10299
+ #ifndef _WINSOCKAPI_
10300
+ #define _WINSOCKAPI_
10301
+ #endif
10296
10302
  #include <windows.h>
10303
+
10304
+ #undef CreateDirectory
10305
+ #undef MoveFile
10306
+ #undef RemoveDirectory
10307
+
10297
10308
  #include <delayimp.h>
10298
10309
 
10299
10310
  extern "C" {
@@ -10301,7 +10312,7 @@ extern "C" {
10301
10312
  This is interesting: Windows would normally require a duckdb.dll being on the DLL search path when we load an extension
10302
10313
  using LoadLibrary(). However, there is likely no such dll, because DuckDB was statically linked, or is running as part
10303
10314
  of an R or Python module with a completely different name (that we don't know) or something of the sorts. Amazingly,
10304
- Windows supports lazy-loading DLLs by linking them with /DELAYLOAD. Then a callback will be triggerd whenever we access
10315
+ Windows supports lazy-loading DLLs by linking them with /DELAYLOAD. Then a callback will be triggered whenever we access
10305
10316
  symbols in the extension. Since DuckDB is already running in the host process (hopefully), we can use
10306
10317
  GetModuleHandle(NULL) to return the current process so the symbols are looked for there. See here for another
10307
10318
  explanation of this crazy process:
@@ -10339,8 +10350,9 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
10339
10350
 
10340
10351
 
10341
10352
 
10353
+ #ifndef DUCKDB_API
10342
10354
  #ifdef _WIN32
10343
- #ifdef DUCKDB_BUILD_LIBRARY
10355
+ #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
10344
10356
  #define DUCKDB_API __declspec(dllexport)
10345
10357
  #else
10346
10358
  #define DUCKDB_API __declspec(dllimport)
@@ -10348,6 +10360,7 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
10348
10360
  #else
10349
10361
  #define DUCKDB_API
10350
10362
  #endif
10363
+ #endif
10351
10364
 
10352
10365
  #include <stdbool.h>
10353
10366
  #include <stdint.h>
@@ -11901,14 +11914,11 @@ class TableCatalogEntry;
11901
11914
  class Connection;
11902
11915
 
11903
11916
  //! The Appender class can be used to append elements to a table.
11904
- class Appender {
11917
+ class BaseAppender {
11918
+ protected:
11905
11919
  //! The amount of chunks that will be gathered in the chunk collection before flushing
11906
11920
  static constexpr const idx_t FLUSH_COUNT = 100;
11907
11921
 
11908
- //! A reference to a database connection that created this appender
11909
- shared_ptr<ClientContext> context;
11910
- //! The table description (including column names)
11911
- unique_ptr<TableDescription> description;
11912
11922
  //! The append types
11913
11923
  vector<LogicalType> types;
11914
11924
  //! The buffered data for the append
@@ -11919,9 +11929,9 @@ class Appender {
11919
11929
  idx_t column = 0;
11920
11930
 
11921
11931
  public:
11922
- DUCKDB_API Appender(Connection &con, const string &schema_name, const string &table_name);
11923
- DUCKDB_API Appender(Connection &con, const string &table_name);
11924
- DUCKDB_API ~Appender();
11932
+ DUCKDB_API BaseAppender();
11933
+ DUCKDB_API BaseAppender(vector<LogicalType> types);
11934
+ DUCKDB_API virtual ~BaseAppender();
11925
11935
 
11926
11936
  //! Begins a new row append, after calling this the other AppendX() functions
11927
11937
  //! should be called the correct amount of times. After that,
@@ -11957,7 +11967,9 @@ public:
11957
11967
  return column;
11958
11968
  }
11959
11969
 
11960
- private:
11970
+ protected:
11971
+ void Destructor();
11972
+ virtual void FlushInternal(ChunkCollection &collection) = 0;
11961
11973
  void InitializeChunk();
11962
11974
  void FlushChunk();
11963
11975
 
@@ -11979,46 +11991,75 @@ private:
11979
11991
  void AppendValue(const Value &value);
11980
11992
  };
11981
11993
 
11994
+ class Appender : public BaseAppender {
11995
+ //! A reference to a database connection that created this appender
11996
+ shared_ptr<ClientContext> context;
11997
+ //! The table description (including column names)
11998
+ unique_ptr<TableDescription> description;
11999
+
12000
+ public:
12001
+ DUCKDB_API Appender(Connection &con, const string &schema_name, const string &table_name);
12002
+ DUCKDB_API Appender(Connection &con, const string &table_name);
12003
+ DUCKDB_API ~Appender() override;
12004
+
12005
+ protected:
12006
+ void FlushInternal(ChunkCollection &collection) override;
12007
+ };
12008
+
12009
+ class InternalAppender : public BaseAppender {
12010
+ //! The client context
12011
+ ClientContext &context;
12012
+ //! The internal table entry to append to
12013
+ TableCatalogEntry &table;
12014
+
12015
+ public:
12016
+ DUCKDB_API InternalAppender(ClientContext &context, TableCatalogEntry &table);
12017
+ DUCKDB_API ~InternalAppender() override;
12018
+
12019
+ protected:
12020
+ void FlushInternal(ChunkCollection &collection) override;
12021
+ };
12022
+
11982
12023
  template <>
11983
- void DUCKDB_API Appender::Append(bool value);
12024
+ DUCKDB_API void BaseAppender::Append(bool value);
11984
12025
  template <>
11985
- void DUCKDB_API Appender::Append(int8_t value);
12026
+ DUCKDB_API void BaseAppender::Append(int8_t value);
11986
12027
  template <>
11987
- void DUCKDB_API Appender::Append(int16_t value);
12028
+ DUCKDB_API void BaseAppender::Append(int16_t value);
11988
12029
  template <>
11989
- void DUCKDB_API Appender::Append(int32_t value);
12030
+ DUCKDB_API void BaseAppender::Append(int32_t value);
11990
12031
  template <>
11991
- void DUCKDB_API Appender::Append(int64_t value);
12032
+ DUCKDB_API void BaseAppender::Append(int64_t value);
11992
12033
  template <>
11993
- void DUCKDB_API Appender::Append(hugeint_t value);
12034
+ DUCKDB_API void BaseAppender::Append(hugeint_t value);
11994
12035
  template <>
11995
- void DUCKDB_API Appender::Append(uint8_t value);
12036
+ DUCKDB_API void BaseAppender::Append(uint8_t value);
11996
12037
  template <>
11997
- void DUCKDB_API Appender::Append(uint16_t value);
12038
+ DUCKDB_API void BaseAppender::Append(uint16_t value);
11998
12039
  template <>
11999
- void DUCKDB_API Appender::Append(uint32_t value);
12040
+ DUCKDB_API void BaseAppender::Append(uint32_t value);
12000
12041
  template <>
12001
- void DUCKDB_API Appender::Append(uint64_t value);
12042
+ DUCKDB_API void BaseAppender::Append(uint64_t value);
12002
12043
  template <>
12003
- void DUCKDB_API Appender::Append(float value);
12044
+ DUCKDB_API void BaseAppender::Append(float value);
12004
12045
  template <>
12005
- void DUCKDB_API Appender::Append(double value);
12046
+ DUCKDB_API void BaseAppender::Append(double value);
12006
12047
  template <>
12007
- void DUCKDB_API Appender::Append(date_t value);
12048
+ DUCKDB_API void BaseAppender::Append(date_t value);
12008
12049
  template <>
12009
- void DUCKDB_API Appender::Append(dtime_t value);
12050
+ DUCKDB_API void BaseAppender::Append(dtime_t value);
12010
12051
  template <>
12011
- void DUCKDB_API Appender::Append(timestamp_t value);
12052
+ DUCKDB_API void BaseAppender::Append(timestamp_t value);
12012
12053
  template <>
12013
- void DUCKDB_API Appender::Append(interval_t value);
12054
+ DUCKDB_API void BaseAppender::Append(interval_t value);
12014
12055
  template <>
12015
- void DUCKDB_API Appender::Append(const char *value);
12056
+ DUCKDB_API void BaseAppender::Append(const char *value);
12016
12057
  template <>
12017
- void DUCKDB_API Appender::Append(string_t value);
12058
+ DUCKDB_API void BaseAppender::Append(string_t value);
12018
12059
  template <>
12019
- void DUCKDB_API Appender::Append(Value value);
12060
+ DUCKDB_API void BaseAppender::Append(Value value);
12020
12061
  template <>
12021
- void DUCKDB_API Appender::Append(std::nullptr_t value);
12062
+ DUCKDB_API void BaseAppender::Append(std::nullptr_t value);
12022
12063
 
12023
12064
  } // namespace duckdb
12024
12065
  //===----------------------------------------------------------------------===//
@@ -12182,22 +12223,21 @@ enum class ConstraintType : uint8_t {
12182
12223
  //! Constraint is the base class of any type of table constraint.
12183
12224
  class Constraint {
12184
12225
  public:
12185
- explicit Constraint(ConstraintType type) : type(type) {};
12186
- virtual ~Constraint() {
12187
- }
12226
+ DUCKDB_API explicit Constraint(ConstraintType type);
12227
+ DUCKDB_API virtual ~Constraint();
12188
12228
 
12189
12229
  ConstraintType type;
12190
12230
 
12191
12231
  public:
12192
- virtual string ToString() const = 0;
12193
- void Print();
12232
+ DUCKDB_API virtual string ToString() const = 0;
12233
+ DUCKDB_API void Print();
12194
12234
 
12195
- virtual unique_ptr<Constraint> Copy() = 0;
12235
+ DUCKDB_API virtual unique_ptr<Constraint> Copy() = 0;
12196
12236
  //! Serializes a Constraint to a stand-alone binary blob
12197
- virtual void Serialize(Serializer &serializer);
12237
+ DUCKDB_API virtual void Serialize(Serializer &serializer);
12198
12238
  //! Deserializes a blob back into a Constraint, returns NULL if
12199
12239
  //! deserialization is not possible
12200
- static unique_ptr<Constraint> Deserialize(Deserializer &source);
12240
+ DUCKDB_API static unique_ptr<Constraint> Deserialize(Deserializer &source);
12201
12241
  };
12202
12242
  } // namespace duckdb
12203
12243
 
@@ -12285,7 +12325,7 @@ public:
12285
12325
 
12286
12326
  //! Returns the column index of the specified column name.
12287
12327
  //! If the column does not exist:
12288
- //! If if_exists is true, returns INVALID_INDEX
12328
+ //! If if_exists is true, returns DConstants::INVALID_INDEX
12289
12329
  //! If if_exists is false, throws an exception
12290
12330
  idx_t GetColumnIndex(string &name, bool if_exists = false);
12291
12331
 
@@ -12324,21 +12364,21 @@ class CatalogSet {
12324
12364
  friend class DependencyManager;
12325
12365
 
12326
12366
  public:
12327
- explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
12367
+ DUCKDB_API explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
12328
12368
 
12329
12369
  //! Create an entry in the catalog set. Returns whether or not it was
12330
12370
  //! successful.
12331
- bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
12332
- unordered_set<CatalogEntry *> &dependencies);
12371
+ DUCKDB_API bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
12372
+ unordered_set<CatalogEntry *> &dependencies);
12333
12373
 
12334
- bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
12374
+ DUCKDB_API bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
12335
12375
 
12336
- bool DropEntry(ClientContext &context, const string &name, bool cascade);
12376
+ DUCKDB_API bool DropEntry(ClientContext &context, const string &name, bool cascade);
12337
12377
 
12338
12378
  void CleanupEntry(CatalogEntry *catalog_entry);
12339
12379
 
12340
12380
  //! Returns the entry with the specified name
12341
- CatalogEntry *GetEntry(ClientContext &context, const string &name);
12381
+ DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &name);
12342
12382
 
12343
12383
  //! Gets the entry that is most similar to the given name (i.e. smallest levenshtein distance), or empty string if
12344
12384
  //! none is found. The returned pair consists of the entry name and the distance (smaller means closer).
@@ -12349,9 +12389,9 @@ public:
12349
12389
  void Undo(CatalogEntry *entry);
12350
12390
 
12351
12391
  //! Scan the catalog set, invoking the callback method for every committed entry
12352
- void Scan(const std::function<void(CatalogEntry *)> &callback);
12392
+ DUCKDB_API void Scan(const std::function<void(CatalogEntry *)> &callback);
12353
12393
  //! Scan the catalog set, invoking the callback method for every entry
12354
- void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
12394
+ DUCKDB_API void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
12355
12395
 
12356
12396
  template <class T>
12357
12397
  vector<T *> GetEntries(ClientContext &context) {
@@ -12360,8 +12400,8 @@ public:
12360
12400
  return result;
12361
12401
  }
12362
12402
 
12363
- static bool HasConflict(ClientContext &context, transaction_t timestamp);
12364
- static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
12403
+ DUCKDB_API static bool HasConflict(ClientContext &context, transaction_t timestamp);
12404
+ DUCKDB_API static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
12365
12405
 
12366
12406
  CatalogEntry *GetEntryFromIndex(idx_t index);
12367
12407
  void UpdateTimestamp(CatalogEntry *entry, transaction_t timestamp);
@@ -12512,7 +12552,6 @@ private:
12512
12552
  } // namespace duckdb
12513
12553
 
12514
12554
 
12515
-
12516
12555
  //===----------------------------------------------------------------------===//
12517
12556
  // DuckDB
12518
12557
  //
@@ -12528,24 +12567,6 @@ private:
12528
12567
  namespace duckdb {
12529
12568
  using std::deque;
12530
12569
  }
12531
- //===----------------------------------------------------------------------===//
12532
- // DuckDB
12533
- //
12534
- // duckdb/common/enums/output_type.hpp
12535
- //
12536
- //
12537
- //===----------------------------------------------------------------------===//
12538
-
12539
-
12540
-
12541
-
12542
-
12543
- namespace duckdb {
12544
-
12545
- enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
12546
-
12547
- } // namespace duckdb
12548
-
12549
12570
 
12550
12571
  //===----------------------------------------------------------------------===//
12551
12572
  // DuckDB
@@ -12697,6 +12718,7 @@ enum class PhysicalOperatorType : uint8_t {
12697
12718
  // Helpers
12698
12719
  // -----------------------------
12699
12720
  EXPLAIN,
12721
+ EXPLAIN_ANALYZE,
12700
12722
  EMPTY_RESULT,
12701
12723
  EXECUTE,
12702
12724
  PREPARE,
@@ -12955,14 +12977,13 @@ struct ParallelState;
12955
12977
  class TableFilterSet;
12956
12978
 
12957
12979
  struct FunctionOperatorData {
12958
- virtual ~FunctionOperatorData() {
12959
- }
12980
+ DUCKDB_API virtual ~FunctionOperatorData();
12960
12981
  };
12961
12982
 
12962
12983
  struct TableFilterCollection {
12984
+ DUCKDB_API explicit TableFilterCollection(TableFilterSet *table_filters);
12985
+
12963
12986
  TableFilterSet *table_filters;
12964
- explicit TableFilterCollection(TableFilterSet *table_filters) : table_filters(table_filters) {
12965
- }
12966
12987
  };
12967
12988
 
12968
12989
  typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, vector<Value> &inputs,
@@ -13007,6 +13028,7 @@ typedef string (*table_function_to_string_t)(const FunctionData *bind_data);
13007
13028
 
13008
13029
  class TableFunction : public SimpleNamedParameterFunction {
13009
13030
  public:
13031
+ DUCKDB_API
13010
13032
  TableFunction(string name, vector<LogicalType> arguments, table_function_t function,
13011
13033
  table_function_bind_t bind = nullptr, table_function_init_t init = nullptr,
13012
13034
  table_statistics_t statistics = nullptr, table_function_cleanup_t cleanup = nullptr,
@@ -13017,14 +13039,8 @@ public:
13017
13039
  table_function_parallel_t parallel_function = nullptr,
13018
13040
  table_function_init_parallel_t parallel_init = nullptr,
13019
13041
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
13020
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr)
13021
- : SimpleNamedParameterFunction(std::move(name), move(arguments)), bind(bind), init(init), function(function),
13022
- statistics(statistics), cleanup(cleanup), dependency(dependency), cardinality(cardinality),
13023
- pushdown_complex_filter(pushdown_complex_filter), to_string(to_string), max_threads(max_threads),
13024
- init_parallel_state(init_parallel_state), parallel_function(parallel_function), parallel_init(parallel_init),
13025
- parallel_state_next(parallel_state_next), table_scan_progress(query_progress),
13026
- projection_pushdown(projection_pushdown), filter_pushdown(filter_pushdown) {
13027
- }
13042
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
13043
+ DUCKDB_API
13028
13044
  TableFunction(const vector<LogicalType> &arguments, table_function_t function, table_function_bind_t bind = nullptr,
13029
13045
  table_function_init_t init = nullptr, table_statistics_t statistics = nullptr,
13030
13046
  table_function_cleanup_t cleanup = nullptr, table_function_dependency_t dependency = nullptr,
@@ -13035,13 +13051,8 @@ public:
13035
13051
  table_function_parallel_t parallel_function = nullptr,
13036
13052
  table_function_init_parallel_t parallel_init = nullptr,
13037
13053
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
13038
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr)
13039
- : TableFunction(string(), arguments, function, bind, init, statistics, cleanup, dependency, cardinality,
13040
- pushdown_complex_filter, to_string, max_threads, init_parallel_state, parallel_function,
13041
- parallel_init, parallel_state_next, projection_pushdown, filter_pushdown, query_progress) {
13042
- }
13043
- TableFunction() : SimpleNamedParameterFunction("", {}) {
13044
- }
13054
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
13055
+ DUCKDB_API TableFunction();
13045
13056
 
13046
13057
  //! Bind function
13047
13058
  //! This function is used for determining the return type of a table producing function and returning bind data
@@ -13089,10 +13100,6 @@ public:
13089
13100
  //! Whether or not the table function supports filter pushdown. If not supported a filter will be added
13090
13101
  //! that applies the table filter directly.
13091
13102
  bool filter_pushdown;
13092
-
13093
- string ToString() override {
13094
- return SimpleNamedParameterFunction::ToString();
13095
- }
13096
13103
  };
13097
13104
 
13098
13105
  } // namespace duckdb
@@ -13177,6 +13184,7 @@ namespace duckdb {
13177
13184
  struct ConcurrentQueue;
13178
13185
  struct QueueProducerToken;
13179
13186
  class ClientContext;
13187
+ class DatabaseInstance;
13180
13188
  class TaskScheduler;
13181
13189
 
13182
13190
  struct SchedulerThread;
@@ -13200,6 +13208,7 @@ public:
13200
13208
  ~TaskScheduler();
13201
13209
 
13202
13210
  static TaskScheduler &GetScheduler(ClientContext &context);
13211
+ static TaskScheduler &GetScheduler(DatabaseInstance &db);
13203
13212
 
13204
13213
  unique_ptr<ProducerToken> CreateProducer();
13205
13214
  //! Schedule a task to be executed by the task scheduler
@@ -13444,7 +13453,7 @@ public:
13444
13453
  //! Starts the thread
13445
13454
  void Start();
13446
13455
  //! Stops the thread
13447
- void Stop();
13456
+ void Stop(bool success = true);
13448
13457
  //! Gets current percentage
13449
13458
  int GetCurrentPercentage();
13450
13459
 
@@ -13461,7 +13470,7 @@ private:
13461
13470
  std::condition_variable c;
13462
13471
  mutex m;
13463
13472
  #endif
13464
- idx_t show_progress_after;
13473
+ atomic<idx_t> show_progress_after;
13465
13474
  idx_t time_update_bar;
13466
13475
  atomic<int> current_percentage;
13467
13476
  atomic<bool> stop;
@@ -13547,6 +13556,75 @@ private:
13547
13556
 
13548
13557
  #include <random>
13549
13558
 
13559
+ //===----------------------------------------------------------------------===//
13560
+ // DuckDB
13561
+ //
13562
+ // duckdb/main/client_config.hpp
13563
+ //
13564
+ //
13565
+ //===----------------------------------------------------------------------===//
13566
+
13567
+
13568
+
13569
+
13570
+
13571
+ //===----------------------------------------------------------------------===//
13572
+ // DuckDB
13573
+ //
13574
+ // duckdb/common/enums/output_type.hpp
13575
+ //
13576
+ //
13577
+ //===----------------------------------------------------------------------===//
13578
+
13579
+
13580
+
13581
+
13582
+
13583
+ namespace duckdb {
13584
+
13585
+ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
13586
+
13587
+ } // namespace duckdb
13588
+
13589
+
13590
+
13591
+ namespace duckdb {
13592
+ class ClientContext;
13593
+
13594
+ struct ClientConfig {
13595
+ //! If the progress bar is enabled or not.
13596
+ bool enable_progress_bar = false;
13597
+ //! If the print of the progress bar is enabled
13598
+ bool print_progress_bar = true;
13599
+ //! The wait time before showing the progress bar
13600
+ int wait_time = 2000;
13601
+
13602
+ // Whether or not aggressive query verification is enabled
13603
+ bool query_verification_enabled = false;
13604
+ //! Enable the running of optimizers
13605
+ bool enable_optimizer = true;
13606
+ //! Force parallelism of small tables, used for testing
13607
+ bool verify_parallelism = false;
13608
+ //! Force index join independent of table cardinality, used for testing
13609
+ bool force_index_join = false;
13610
+ //! Force out-of-core computation for operators that support it, used for testing
13611
+ bool force_external = false;
13612
+ //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13613
+ //! elements)
13614
+ idx_t perfect_ht_threshold = 12;
13615
+
13616
+ //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13617
+ ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13618
+
13619
+ //! Generic options
13620
+ case_insensitive_map_t<Value> set_variables;
13621
+
13622
+ public:
13623
+ static ClientConfig &GetConfig(ClientContext &context);
13624
+ };
13625
+
13626
+ } // namespace duckdb
13627
+
13550
13628
 
13551
13629
  namespace duckdb {
13552
13630
  class Appender;
@@ -13591,35 +13669,12 @@ public:
13591
13669
 
13592
13670
  //! The Progress Bar
13593
13671
  unique_ptr<ProgressBar> progress_bar;
13594
- //! If the progress bar is enabled or not.
13595
- bool enable_progress_bar = false;
13596
- //! If the print of the progress bar is enabled
13597
- bool print_progress_bar = true;
13598
- //! The wait time before showing the progress bar
13599
- int wait_time = 2000;
13600
13672
 
13601
13673
  unique_ptr<SchemaCatalogEntry> temporary_objects;
13602
13674
  unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
13603
13675
 
13604
- case_insensitive_map_t<Value> set_variables;
13605
-
13606
- // Whether or not aggressive query verification is enabled
13607
- bool query_verification_enabled = false;
13608
- //! Enable the running of optimizers
13609
- bool enable_optimizer = true;
13610
- //! Force parallelism of small tables, used for testing
13611
- bool verify_parallelism = false;
13612
- //! Force index join independent of table cardinality, used for testing
13613
- bool force_index_join = false;
13614
- //! Force out-of-core computation for operators that support it, used for testing
13615
- bool force_external = false;
13616
- //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13617
- //! elements)
13618
- idx_t perfect_ht_threshold = 12;
13619
13676
  //! The writer used to log queries (if logging is enabled)
13620
13677
  unique_ptr<BufferedFileWriter> log_query_writer;
13621
- //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13622
- ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13623
13678
  //! The random generator used by random(). Its seed value can be set by setseed().
13624
13679
  std::mt19937 random_engine;
13625
13680
 
@@ -13627,6 +13682,9 @@ public:
13627
13682
 
13628
13683
  unique_ptr<FileOpener> file_opener;
13629
13684
 
13685
+ //! The client configuration
13686
+ ClientConfig config;
13687
+
13630
13688
  public:
13631
13689
  DUCKDB_API Transaction &ActiveTransaction() {
13632
13690
  return transaction.ActiveTransaction();