duckdb 0.3.2-dev5.0 → 0.3.2-dev521.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 +46478 -30756
  3. package/src/duckdb.hpp +773 -631
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 "a6073fb5c"
14
- #define DUCKDB_VERSION "0.3.2-dev5"
13
+ #define DUCKDB_SOURCE_ID "958511672"
14
+ #define DUCKDB_VERSION "0.3.2-dev521"
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;
@@ -904,6 +916,9 @@ enum class LogicalTypeId : uint8_t {
904
916
  USMALLINT = 29,
905
917
  UINTEGER = 30,
906
918
  UBIGINT = 31,
919
+ TIMESTAMP_TZ = 32,
920
+ DATE_TZ = 33,
921
+ TIME_TZ = 34,
907
922
 
908
923
 
909
924
  HUGEINT = 50,
@@ -925,42 +940,38 @@ struct LogicalType {
925
940
  DUCKDB_API LogicalType();
926
941
  DUCKDB_API LogicalType(LogicalTypeId id); // NOLINT: Allow implicit conversion from `LogicalTypeId`
927
942
  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_)) {}
943
+ DUCKDB_API LogicalType(const LogicalType &other);
944
+ DUCKDB_API LogicalType(LogicalType &&other) noexcept;
934
945
 
935
946
  DUCKDB_API ~LogicalType();
936
947
 
937
- LogicalTypeId id() const {
948
+ inline LogicalTypeId id() const {
938
949
  return id_;
939
950
  }
940
- PhysicalType InternalType() const {
951
+ inline PhysicalType InternalType() const {
941
952
  return physical_type_;
942
953
  }
943
- const ExtraTypeInfo *AuxInfo() const {
954
+ inline const ExtraTypeInfo *AuxInfo() const {
944
955
  return type_info_.get();
945
956
  }
946
957
 
947
958
  // copy assignment
948
- LogicalType& operator=(const LogicalType &other) {
959
+ inline LogicalType& operator=(const LogicalType &other) {
949
960
  id_ = other.id_;
950
961
  physical_type_ = other.physical_type_;
951
962
  type_info_ = other.type_info_;
952
963
  return *this;
953
964
  }
954
965
  // move assignment
955
- LogicalType& operator=(LogicalType&& other) {
966
+ inline LogicalType& operator=(LogicalType&& other) {
956
967
  id_ = other.id_;
957
968
  physical_type_ = other.physical_type_;
958
969
  type_info_ = move(other.type_info_);
959
970
  return *this;
960
971
  }
961
972
 
962
- bool operator==(const LogicalType &rhs) const;
963
- bool operator!=(const LogicalType &rhs) const {
973
+ DUCKDB_API bool operator==(const LogicalType &rhs) const;
974
+ inline bool operator!=(const LogicalType &rhs) const {
964
975
  return !(*this == rhs);
965
976
  }
966
977
 
@@ -990,34 +1001,37 @@ private:
990
1001
  PhysicalType GetInternalType();
991
1002
 
992
1003
  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;
1004
+ static constexpr const LogicalTypeId SQLNULL = LogicalTypeId::SQLNULL;
1005
+ static constexpr const LogicalTypeId BOOLEAN = LogicalTypeId::BOOLEAN;
1006
+ static constexpr const LogicalTypeId TINYINT = LogicalTypeId::TINYINT;
1007
+ static constexpr const LogicalTypeId UTINYINT = LogicalTypeId::UTINYINT;
1008
+ static constexpr const LogicalTypeId SMALLINT = LogicalTypeId::SMALLINT;
1009
+ static constexpr const LogicalTypeId USMALLINT = LogicalTypeId::USMALLINT;
1010
+ static constexpr const LogicalTypeId INTEGER = LogicalTypeId::INTEGER;
1011
+ static constexpr const LogicalTypeId UINTEGER = LogicalTypeId::UINTEGER;
1012
+ static constexpr const LogicalTypeId BIGINT = LogicalTypeId::BIGINT;
1013
+ static constexpr const LogicalTypeId UBIGINT = LogicalTypeId::UBIGINT;
1014
+ static constexpr const LogicalTypeId FLOAT = LogicalTypeId::FLOAT;
1015
+ static constexpr const LogicalTypeId DOUBLE = LogicalTypeId::DOUBLE;
1016
+ static constexpr const LogicalTypeId DATE = LogicalTypeId::DATE;
1017
+ static constexpr const LogicalTypeId TIMESTAMP = LogicalTypeId::TIMESTAMP;
1018
+ static constexpr const LogicalTypeId TIMESTAMP_S = LogicalTypeId::TIMESTAMP_SEC;
1019
+ static constexpr const LogicalTypeId TIMESTAMP_MS = LogicalTypeId::TIMESTAMP_MS;
1020
+ static constexpr const LogicalTypeId TIMESTAMP_NS = LogicalTypeId::TIMESTAMP_NS;
1021
+ static constexpr const LogicalTypeId TIME = LogicalTypeId::TIME;
1022
+ static constexpr const LogicalTypeId TIMESTAMP_TZ = LogicalTypeId::TIMESTAMP_TZ;
1023
+ static constexpr const LogicalTypeId DATE_TZ = LogicalTypeId::DATE_TZ;
1024
+ static constexpr const LogicalTypeId TIME_TZ = LogicalTypeId::TIME_TZ;
1025
+ static constexpr const LogicalTypeId VARCHAR = LogicalTypeId::VARCHAR;
1026
+ static constexpr const LogicalTypeId ANY = LogicalTypeId::ANY;
1027
+ static constexpr const LogicalTypeId BLOB = LogicalTypeId::BLOB;
1028
+ static constexpr const LogicalTypeId INTERVAL = LogicalTypeId::INTERVAL;
1029
+ static constexpr const LogicalTypeId HUGEINT = LogicalTypeId::HUGEINT;
1030
+ static constexpr const LogicalTypeId UUID = LogicalTypeId::UUID;
1031
+ static constexpr const LogicalTypeId HASH = LogicalTypeId::HASH;
1032
+ static constexpr const LogicalTypeId POINTER = LogicalTypeId::POINTER;
1033
+ static constexpr const LogicalTypeId TABLE = LogicalTypeId::TABLE;
1034
+ static constexpr const LogicalTypeId INVALID = LogicalTypeId::INVALID;
1021
1035
 
1022
1036
  // explicitly allowing these functions to be capitalized to be in-line with the remaining functions
1023
1037
  DUCKDB_API static LogicalType DECIMAL(int width, int scale); // NOLINT
@@ -1025,6 +1039,7 @@ public:
1025
1039
  DUCKDB_API static LogicalType LIST( LogicalType child); // NOLINT
1026
1040
  DUCKDB_API static LogicalType STRUCT( child_list_t<LogicalType> children); // NOLINT
1027
1041
  DUCKDB_API static LogicalType MAP( child_list_t<LogicalType> children); // NOLINT
1042
+ DUCKDB_API static LogicalType MAP(LogicalType key, LogicalType value); // NOLINT
1028
1043
  DUCKDB_API static LogicalType ENUM(const string &enum_name, const vector<string> &ordered_data); // NOLINT
1029
1044
  DUCKDB_API static LogicalType USER(const string &user_type_name); // NOLINT
1030
1045
  //! A list of all NUMERIC types (integral and floating point types)
@@ -1131,7 +1146,7 @@ bool IsValidType() {
1131
1146
  extern const LogicalType LOGICAL_ROW_TYPE;
1132
1147
  extern const PhysicalType ROW_TYPE;
1133
1148
 
1134
- string TypeIdToString(PhysicalType type);
1149
+ DUCKDB_API string TypeIdToString(PhysicalType type);
1135
1150
  idx_t GetTypeIdSize(PhysicalType type);
1136
1151
  bool TypeIsConstantSize(PhysicalType type);
1137
1152
  bool TypeIsIntegral(PhysicalType type);
@@ -1158,15 +1173,9 @@ enum class ExceptionFormatValueType : uint8_t {
1158
1173
  };
1159
1174
 
1160
1175
  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
- }
1176
+ DUCKDB_API ExceptionFormatValue(double dbl_val); // NOLINT
1177
+ DUCKDB_API ExceptionFormatValue(int64_t int_val); // NOLINT
1178
+ DUCKDB_API ExceptionFormatValue(string str_val); // NOLINT
1170
1179
 
1171
1180
  ExceptionFormatValueType type;
1172
1181
 
@@ -1183,19 +1192,19 @@ public:
1183
1192
  };
1184
1193
 
1185
1194
  template <>
1186
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(PhysicalType value);
1195
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(PhysicalType value);
1187
1196
  template <>
1188
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(LogicalType value);
1197
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(LogicalType value);
1189
1198
  template <>
1190
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(float value);
1199
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(float value);
1191
1200
  template <>
1192
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(double value);
1201
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(double value);
1193
1202
  template <>
1194
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(string value);
1203
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(string value);
1195
1204
  template <>
1196
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(const char *value);
1205
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(const char *value);
1197
1206
  template <>
1198
- ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(char *value);
1207
+ DUCKDB_API ExceptionFormatValue ExceptionFormatValue::CreateFormatValue(char *value);
1199
1208
 
1200
1209
  } // namespace duckdb
1201
1210
 
@@ -1266,15 +1275,15 @@ enum class ExceptionType {
1266
1275
 
1267
1276
  class Exception : public std::exception {
1268
1277
  public:
1269
- explicit Exception(const string &msg);
1270
- Exception(ExceptionType exception_type, const string &message);
1278
+ DUCKDB_API explicit Exception(const string &msg);
1279
+ DUCKDB_API Exception(ExceptionType exception_type, const string &message);
1271
1280
 
1272
1281
  ExceptionType type;
1273
1282
 
1274
1283
  public:
1275
- const char *what() const noexcept override;
1284
+ DUCKDB_API const char *what() const noexcept override;
1276
1285
 
1277
- string ExceptionTypeToString(ExceptionType type);
1286
+ DUCKDB_API string ExceptionTypeToString(ExceptionType type);
1278
1287
 
1279
1288
  template <typename... Args>
1280
1289
  static string ConstructMessage(const string &msg, Args... params) {
@@ -1282,7 +1291,7 @@ public:
1282
1291
  return ConstructMessageRecursive(msg, values, params...);
1283
1292
  }
1284
1293
 
1285
- static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values);
1294
+ DUCKDB_API static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values);
1286
1295
 
1287
1296
  template <class T, typename... Args>
1288
1297
  static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values, T param,
@@ -1291,6 +1300,8 @@ public:
1291
1300
  return ConstructMessageRecursive(msg, values, params...);
1292
1301
  }
1293
1302
 
1303
+ DUCKDB_API static bool UncaughtException();
1304
+
1294
1305
  private:
1295
1306
  string exception_message_;
1296
1307
  };
@@ -1302,13 +1313,12 @@ private:
1302
1313
  //! Exceptions that are StandardExceptions do NOT invalidate the current transaction when thrown
1303
1314
  class StandardException : public Exception {
1304
1315
  public:
1305
- StandardException(ExceptionType exception_type, string message) : Exception(exception_type, message) {
1306
- }
1316
+ DUCKDB_API StandardException(ExceptionType exception_type, const string &message);
1307
1317
  };
1308
1318
 
1309
1319
  class CatalogException : public StandardException {
1310
1320
  public:
1311
- explicit CatalogException(const string &msg);
1321
+ DUCKDB_API explicit CatalogException(const string &msg);
1312
1322
 
1313
1323
  template <typename... Args>
1314
1324
  explicit CatalogException(const string &msg, Args... params) : CatalogException(ConstructMessage(msg, params...)) {
@@ -1317,7 +1327,7 @@ public:
1317
1327
 
1318
1328
  class ParserException : public StandardException {
1319
1329
  public:
1320
- explicit ParserException(const string &msg);
1330
+ DUCKDB_API explicit ParserException(const string &msg);
1321
1331
 
1322
1332
  template <typename... Args>
1323
1333
  explicit ParserException(const string &msg, Args... params) : ParserException(ConstructMessage(msg, params...)) {
@@ -1326,7 +1336,7 @@ public:
1326
1336
 
1327
1337
  class BinderException : public StandardException {
1328
1338
  public:
1329
- explicit BinderException(const string &msg);
1339
+ DUCKDB_API explicit BinderException(const string &msg);
1330
1340
 
1331
1341
  template <typename... Args>
1332
1342
  explicit BinderException(const string &msg, Args... params) : BinderException(ConstructMessage(msg, params...)) {
@@ -1335,7 +1345,7 @@ public:
1335
1345
 
1336
1346
  class ConversionException : public Exception {
1337
1347
  public:
1338
- explicit ConversionException(const string &msg);
1348
+ DUCKDB_API explicit ConversionException(const string &msg);
1339
1349
 
1340
1350
  template <typename... Args>
1341
1351
  explicit ConversionException(const string &msg, Args... params)
@@ -1345,7 +1355,7 @@ public:
1345
1355
 
1346
1356
  class TransactionException : public Exception {
1347
1357
  public:
1348
- explicit TransactionException(const string &msg);
1358
+ DUCKDB_API explicit TransactionException(const string &msg);
1349
1359
 
1350
1360
  template <typename... Args>
1351
1361
  explicit TransactionException(const string &msg, Args... params)
@@ -1355,7 +1365,7 @@ public:
1355
1365
 
1356
1366
  class NotImplementedException : public Exception {
1357
1367
  public:
1358
- explicit NotImplementedException(const string &msg);
1368
+ DUCKDB_API explicit NotImplementedException(const string &msg);
1359
1369
 
1360
1370
  template <typename... Args>
1361
1371
  explicit NotImplementedException(const string &msg, Args... params)
@@ -1365,7 +1375,7 @@ public:
1365
1375
 
1366
1376
  class OutOfRangeException : public Exception {
1367
1377
  public:
1368
- explicit OutOfRangeException(const string &msg);
1378
+ DUCKDB_API explicit OutOfRangeException(const string &msg);
1369
1379
 
1370
1380
  template <typename... Args>
1371
1381
  explicit OutOfRangeException(const string &msg, Args... params)
@@ -1375,7 +1385,7 @@ public:
1375
1385
 
1376
1386
  class OutOfMemoryException : public Exception {
1377
1387
  public:
1378
- explicit OutOfMemoryException(const string &msg);
1388
+ DUCKDB_API explicit OutOfMemoryException(const string &msg);
1379
1389
 
1380
1390
  template <typename... Args>
1381
1391
  explicit OutOfMemoryException(const string &msg, Args... params)
@@ -1385,7 +1395,7 @@ public:
1385
1395
 
1386
1396
  class SyntaxException : public Exception {
1387
1397
  public:
1388
- explicit SyntaxException(const string &msg);
1398
+ DUCKDB_API explicit SyntaxException(const string &msg);
1389
1399
 
1390
1400
  template <typename... Args>
1391
1401
  explicit SyntaxException(const string &msg, Args... params) : SyntaxException(ConstructMessage(msg, params...)) {
@@ -1394,7 +1404,7 @@ public:
1394
1404
 
1395
1405
  class ConstraintException : public Exception {
1396
1406
  public:
1397
- explicit ConstraintException(const string &msg);
1407
+ DUCKDB_API explicit ConstraintException(const string &msg);
1398
1408
 
1399
1409
  template <typename... Args>
1400
1410
  explicit ConstraintException(const string &msg, Args... params)
@@ -1404,7 +1414,7 @@ public:
1404
1414
 
1405
1415
  class IOException : public Exception {
1406
1416
  public:
1407
- explicit IOException(const string &msg);
1417
+ DUCKDB_API explicit IOException(const string &msg);
1408
1418
 
1409
1419
  template <typename... Args>
1410
1420
  explicit IOException(const string &msg, Args... params) : IOException(ConstructMessage(msg, params...)) {
@@ -1413,7 +1423,7 @@ public:
1413
1423
 
1414
1424
  class SerializationException : public Exception {
1415
1425
  public:
1416
- explicit SerializationException(const string &msg);
1426
+ DUCKDB_API explicit SerializationException(const string &msg);
1417
1427
 
1418
1428
  template <typename... Args>
1419
1429
  explicit SerializationException(const string &msg, Args... params)
@@ -1423,7 +1433,7 @@ public:
1423
1433
 
1424
1434
  class SequenceException : public Exception {
1425
1435
  public:
1426
- explicit SequenceException(const string &msg);
1436
+ DUCKDB_API explicit SequenceException(const string &msg);
1427
1437
 
1428
1438
  template <typename... Args>
1429
1439
  explicit SequenceException(const string &msg, Args... params)
@@ -1433,12 +1443,12 @@ public:
1433
1443
 
1434
1444
  class InterruptException : public Exception {
1435
1445
  public:
1436
- InterruptException();
1446
+ DUCKDB_API InterruptException();
1437
1447
  };
1438
1448
 
1439
1449
  class FatalException : public Exception {
1440
1450
  public:
1441
- explicit FatalException(const string &msg);
1451
+ DUCKDB_API explicit FatalException(const string &msg);
1442
1452
 
1443
1453
  template <typename... Args>
1444
1454
  explicit FatalException(const string &msg, Args... params) : FatalException(ConstructMessage(msg, params...)) {
@@ -1447,7 +1457,7 @@ public:
1447
1457
 
1448
1458
  class InternalException : public Exception {
1449
1459
  public:
1450
- explicit InternalException(const string &msg);
1460
+ DUCKDB_API explicit InternalException(const string &msg);
1451
1461
 
1452
1462
  template <typename... Args>
1453
1463
  explicit InternalException(const string &msg, Args... params)
@@ -1457,7 +1467,7 @@ public:
1457
1467
 
1458
1468
  class InvalidInputException : public Exception {
1459
1469
  public:
1460
- explicit InvalidInputException(const string &msg);
1470
+ DUCKDB_API explicit InvalidInputException(const string &msg);
1461
1471
 
1462
1472
  template <typename... Args>
1463
1473
  explicit InvalidInputException(const string &msg, Args... params)
@@ -1467,28 +1477,28 @@ public:
1467
1477
 
1468
1478
  class CastException : public Exception {
1469
1479
  public:
1470
- CastException(const PhysicalType origType, const PhysicalType newType);
1471
- CastException(const LogicalType &origType, const LogicalType &newType);
1480
+ DUCKDB_API CastException(const PhysicalType origType, const PhysicalType newType);
1481
+ DUCKDB_API CastException(const LogicalType &origType, const LogicalType &newType);
1472
1482
  };
1473
1483
 
1474
1484
  class InvalidTypeException : public Exception {
1475
1485
  public:
1476
- InvalidTypeException(PhysicalType type, const string &msg);
1477
- InvalidTypeException(const LogicalType &type, const string &msg);
1486
+ DUCKDB_API InvalidTypeException(PhysicalType type, const string &msg);
1487
+ DUCKDB_API InvalidTypeException(const LogicalType &type, const string &msg);
1478
1488
  };
1479
1489
 
1480
1490
  class TypeMismatchException : public Exception {
1481
1491
  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);
1492
+ DUCKDB_API TypeMismatchException(const PhysicalType type_1, const PhysicalType type_2, const string &msg);
1493
+ DUCKDB_API TypeMismatchException(const LogicalType &type_1, const LogicalType &type_2, const string &msg);
1484
1494
  };
1485
1495
 
1486
1496
  class ValueOutOfRangeException : public Exception {
1487
1497
  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);
1498
+ DUCKDB_API ValueOutOfRangeException(const int64_t value, const PhysicalType origType, const PhysicalType newType);
1499
+ DUCKDB_API ValueOutOfRangeException(const hugeint_t value, const PhysicalType origType, const PhysicalType newType);
1500
+ DUCKDB_API ValueOutOfRangeException(const double value, const PhysicalType origType, const PhysicalType newType);
1501
+ DUCKDB_API ValueOutOfRangeException(const PhysicalType varType, const idx_t length);
1492
1502
  };
1493
1503
 
1494
1504
  } // namespace duckdb
@@ -1718,7 +1728,9 @@ using std::unordered_map;
1718
1728
 
1719
1729
  namespace duckdb {
1720
1730
 
1721
- enum class FileCompressionType : uint8_t { AUTO_DETECT = 0, UNCOMPRESSED = 1, GZIP = 2 };
1731
+ enum class FileCompressionType : uint8_t { AUTO_DETECT = 0, UNCOMPRESSED = 1, GZIP = 2, ZSTD = 3 };
1732
+
1733
+ FileCompressionType FileCompressionTypeFromString(const string &input);
1722
1734
 
1723
1735
  } // namespace duckdb
1724
1736
 
@@ -1778,7 +1790,7 @@ public:
1778
1790
  idx_t GetFileSize();
1779
1791
  FileType GetType();
1780
1792
 
1781
- protected:
1793
+ //! Closes the file handle.
1782
1794
  virtual void Close() = 0;
1783
1795
 
1784
1796
  public:
@@ -1882,6 +1894,7 @@ public:
1882
1894
 
1883
1895
  //! registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.
1884
1896
  virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
1897
+ virtual void RegisterSubSystem(FileCompressionType compression_type, unique_ptr<FileSystem> fs);
1885
1898
 
1886
1899
  //! Whether or not a sub-system can handle a specific file path
1887
1900
  virtual bool CanHandleFile(const string &fpath);
@@ -1898,6 +1911,8 @@ public:
1898
1911
  //! in a file on-disk are much cheaper than e.g. random reads in a file over the network
1899
1912
  virtual bool OnDiskFile(FileHandle &handle);
1900
1913
 
1914
+ virtual unique_ptr<FileHandle> OpenCompressedFile(unique_ptr<FileHandle> handle, bool write);
1915
+
1901
1916
  //! Create a LocalFileSystem.
1902
1917
  static unique_ptr<FileSystem> CreateLocal();
1903
1918
 
@@ -1923,6 +1938,7 @@ public:
1923
1938
  FileOpener *opener = nullptr);
1924
1939
 
1925
1940
  FileSystem &fs;
1941
+ string path;
1926
1942
  unique_ptr<data_t[]> data;
1927
1943
  idx_t offset;
1928
1944
  idx_t total_written;
@@ -2224,14 +2240,14 @@ struct TemplatedValidityData {
2224
2240
  static constexpr const V MAX_ENTRY = ~V(0);
2225
2241
 
2226
2242
  public:
2227
- explicit TemplatedValidityData(idx_t count) {
2243
+ inline explicit TemplatedValidityData(idx_t count) {
2228
2244
  auto entry_count = EntryCount(count);
2229
2245
  owned_data = unique_ptr<V[]>(new V[entry_count]);
2230
2246
  for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
2231
2247
  owned_data[entry_idx] = MAX_ENTRY;
2232
2248
  }
2233
2249
  }
2234
- TemplatedValidityData(const V *validity_mask, idx_t count) {
2250
+ inline TemplatedValidityData(const V *validity_mask, idx_t count) {
2235
2251
  D_ASSERT(validity_mask);
2236
2252
  auto entry_count = EntryCount(count);
2237
2253
  owned_data = unique_ptr<V[]>(new V[entry_count]);
@@ -2267,14 +2283,14 @@ public:
2267
2283
  static constexpr const int STANDARD_MASK_SIZE = STANDARD_ENTRY_COUNT * sizeof(validity_t);
2268
2284
 
2269
2285
  public:
2270
- TemplatedValidityMask() : validity_mask(nullptr) {
2286
+ inline TemplatedValidityMask() : validity_mask(nullptr) {
2271
2287
  }
2272
- explicit TemplatedValidityMask(idx_t max_count) {
2288
+ inline explicit TemplatedValidityMask(idx_t max_count) {
2273
2289
  Initialize(max_count);
2274
2290
  }
2275
- explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
2291
+ inline explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
2276
2292
  }
2277
- TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
2293
+ inline TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
2278
2294
  Copy(original, count);
2279
2295
  }
2280
2296
 
@@ -2284,7 +2300,7 @@ public:
2284
2300
  inline bool AllValid() const {
2285
2301
  return !validity_mask;
2286
2302
  }
2287
- bool CheckAllValid(idx_t count) const {
2303
+ inline bool CheckAllValid(idx_t count) const {
2288
2304
  if (AllValid()) {
2289
2305
  return true;
2290
2306
  }
@@ -2296,7 +2312,7 @@ public:
2296
2312
  return valid_count == entry_count;
2297
2313
  }
2298
2314
 
2299
- bool CheckAllValid(idx_t to, idx_t from) const {
2315
+ inline bool CheckAllValid(idx_t to, idx_t from) const {
2300
2316
  if (AllValid()) {
2301
2317
  return true;
2302
2318
  }
@@ -2311,7 +2327,7 @@ public:
2311
2327
  inline V *GetData() const {
2312
2328
  return validity_mask;
2313
2329
  }
2314
- void Reset() {
2330
+ inline void Reset() {
2315
2331
  validity_mask = nullptr;
2316
2332
  validity_data.reset();
2317
2333
  }
@@ -2437,19 +2453,19 @@ public:
2437
2453
  }
2438
2454
 
2439
2455
  public:
2440
- void Initialize(validity_t *validity) {
2456
+ inline void Initialize(validity_t *validity) {
2441
2457
  validity_data.reset();
2442
2458
  validity_mask = validity;
2443
2459
  }
2444
- void Initialize(const TemplatedValidityMask &other) {
2460
+ inline void Initialize(const TemplatedValidityMask &other) {
2445
2461
  validity_mask = other.validity_mask;
2446
2462
  validity_data = other.validity_data;
2447
2463
  }
2448
- void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
2464
+ inline void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
2449
2465
  validity_data = make_buffer<ValidityBuffer>(count);
2450
2466
  validity_mask = validity_data->owned_data.get();
2451
2467
  }
2452
- void Copy(const TemplatedValidityMask &other, idx_t count) {
2468
+ inline void Copy(const TemplatedValidityMask &other, idx_t count) {
2453
2469
  if (other.AllValid()) {
2454
2470
  validity_data = nullptr;
2455
2471
  validity_mask = nullptr;
@@ -2466,21 +2482,21 @@ protected:
2466
2482
 
2467
2483
  struct ValidityMask : public TemplatedValidityMask<validity_t> {
2468
2484
  public:
2469
- ValidityMask() : TemplatedValidityMask(nullptr) {
2485
+ inline ValidityMask() : TemplatedValidityMask(nullptr) {
2470
2486
  }
2471
- explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
2487
+ inline explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
2472
2488
  }
2473
- explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
2489
+ inline explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
2474
2490
  }
2475
- ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
2491
+ inline ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
2476
2492
  }
2477
2493
 
2478
2494
  public:
2479
- void Resize(idx_t old_size, idx_t new_size);
2495
+ DUCKDB_API void Resize(idx_t old_size, idx_t new_size);
2480
2496
 
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;
2497
+ DUCKDB_API void Slice(const ValidityMask &other, idx_t offset);
2498
+ DUCKDB_API void Combine(const ValidityMask &other, idx_t count);
2499
+ DUCKDB_API string ToString(idx_t count) const;
2484
2500
  };
2485
2501
 
2486
2502
  } // namespace duckdb
@@ -2512,25 +2528,25 @@ class Value {
2512
2528
 
2513
2529
  public:
2514
2530
  //! Create an empty NULL value of the specified type
2515
- explicit Value(LogicalType type = LogicalType::SQLNULL);
2531
+ DUCKDB_API explicit Value(LogicalType type = LogicalType::SQLNULL);
2516
2532
  //! Create an INTEGER value
2517
- Value(int32_t val); // NOLINT: Allow implicit conversion from `int32_t`
2533
+ DUCKDB_API Value(int32_t val); // NOLINT: Allow implicit conversion from `int32_t`
2518
2534
  //! Create a BIGINT value
2519
- Value(int64_t val); // NOLINT: Allow implicit conversion from `int64_t`
2535
+ DUCKDB_API Value(int64_t val); // NOLINT: Allow implicit conversion from `int64_t`
2520
2536
  //! Create a FLOAT value
2521
- Value(float val); // NOLINT: Allow implicit conversion from `float`
2537
+ DUCKDB_API Value(float val); // NOLINT: Allow implicit conversion from `float`
2522
2538
  //! Create a DOUBLE value
2523
- Value(double val); // NOLINT: Allow implicit conversion from `double`
2539
+ DUCKDB_API Value(double val); // NOLINT: Allow implicit conversion from `double`
2524
2540
  //! Create a VARCHAR value
2525
- Value(const char *val); // NOLINT: Allow implicit conversion from `const char *`
2541
+ DUCKDB_API Value(const char *val); // NOLINT: Allow implicit conversion from `const char *`
2526
2542
  //! Create a NULL value
2527
- Value(std::nullptr_t val); // NOLINT: Allow implicit conversion from `nullptr_t`
2543
+ DUCKDB_API Value(std::nullptr_t val); // NOLINT: Allow implicit conversion from `nullptr_t`
2528
2544
  //! Create a VARCHAR value
2529
- Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2545
+ DUCKDB_API Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2530
2546
  //! Create a VARCHAR value
2531
- Value(string val); // NOLINT: Allow implicit conversion from `string`
2547
+ DUCKDB_API Value(string val); // NOLINT: Allow implicit conversion from `string`
2532
2548
 
2533
- const LogicalType &type() const {
2549
+ inline const LogicalType &type() const {
2534
2550
  return type_;
2535
2551
  }
2536
2552
 
@@ -2572,19 +2588,22 @@ public:
2572
2588
  DUCKDB_API static Value POINTER(uintptr_t value);
2573
2589
  //! Create a date Value from a specified date
2574
2590
  DUCKDB_API static Value DATE(date_t date);
2591
+ DUCKDB_API static Value DATETZ(date_t date);
2575
2592
  //! Create a date Value from a specified date
2576
2593
  DUCKDB_API static Value DATE(int32_t year, int32_t month, int32_t day);
2577
2594
  //! Create a time Value from a specified time
2578
2595
  DUCKDB_API static Value TIME(dtime_t time);
2596
+ DUCKDB_API static Value TIMETZ(dtime_t time);
2579
2597
  //! Create a time Value from a specified time
2580
2598
  DUCKDB_API static Value TIME(int32_t hour, int32_t min, int32_t sec, int32_t micros);
2581
2599
  //! Create a timestamp Value from a specified date/time combination
2582
2600
  DUCKDB_API static Value TIMESTAMP(date_t date, dtime_t time);
2583
2601
  //! Create a timestamp Value from a specified timestamp
2584
2602
  DUCKDB_API static Value TIMESTAMP(timestamp_t timestamp);
2585
- DUCKDB_API static Value TimestampNs(timestamp_t timestamp);
2586
- DUCKDB_API static Value TimestampMs(timestamp_t timestamp);
2587
- DUCKDB_API static Value TimestampSec(timestamp_t timestamp);
2603
+ DUCKDB_API static Value TIMESTAMPNS(timestamp_t timestamp);
2604
+ DUCKDB_API static Value TIMESTAMPMS(timestamp_t timestamp);
2605
+ DUCKDB_API static Value TIMESTAMPSEC(timestamp_t timestamp);
2606
+ DUCKDB_API static Value TIMESTAMPTZ(timestamp_t timestamp);
2588
2607
  //! Create a timestamp Value from a specified timestamp in separate values
2589
2608
  DUCKDB_API static Value TIMESTAMP(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, int32_t sec,
2590
2609
  int32_t micros);
@@ -2605,8 +2624,11 @@ public:
2605
2624
  DUCKDB_API static Value DOUBLE(double value);
2606
2625
  //! Create a struct value with given list of entries
2607
2626
  DUCKDB_API static Value STRUCT(child_list_t<Value> values);
2608
- //! Create a list value with the given entries
2627
+ //! Create a list value with the given entries, list type is inferred from children
2628
+ //! Cannot be called with an empty list, use either EMPTYLIST or LIST with a type instead
2609
2629
  DUCKDB_API static Value LIST(vector<Value> values);
2630
+ //! Create a list value with the given entries
2631
+ DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
2610
2632
  //! Create an empty list with the specified type
2611
2633
  DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
2612
2634
  //! Creat a map value from a (key, value) pair
@@ -2661,32 +2683,32 @@ public:
2661
2683
  //===--------------------------------------------------------------------===//
2662
2684
  // Numeric Operators
2663
2685
  //===--------------------------------------------------------------------===//
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;
2686
+ DUCKDB_API Value operator+(const Value &rhs) const;
2687
+ DUCKDB_API Value operator-(const Value &rhs) const;
2688
+ DUCKDB_API Value operator*(const Value &rhs) const;
2689
+ DUCKDB_API Value operator/(const Value &rhs) const;
2690
+ DUCKDB_API Value operator%(const Value &rhs) const;
2669
2691
 
2670
2692
  //===--------------------------------------------------------------------===//
2671
2693
  // Comparison Operators
2672
2694
  //===--------------------------------------------------------------------===//
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);
2695
+ DUCKDB_API bool operator==(const Value &rhs) const;
2696
+ DUCKDB_API bool operator!=(const Value &rhs) const;
2697
+ DUCKDB_API bool operator<(const Value &rhs) const;
2698
+ DUCKDB_API bool operator>(const Value &rhs) const;
2699
+ DUCKDB_API bool operator<=(const Value &rhs) const;
2700
+ DUCKDB_API bool operator>=(const Value &rhs) const;
2701
+
2702
+ DUCKDB_API bool operator==(const int64_t &rhs) const;
2703
+ DUCKDB_API bool operator!=(const int64_t &rhs) const;
2704
+ DUCKDB_API bool operator<(const int64_t &rhs) const;
2705
+ DUCKDB_API bool operator>(const int64_t &rhs) const;
2706
+ DUCKDB_API bool operator<=(const int64_t &rhs) const;
2707
+ DUCKDB_API bool operator>=(const int64_t &rhs) const;
2708
+
2709
+ DUCKDB_API static bool FloatIsValid(float value);
2710
+ DUCKDB_API static bool DoubleIsValid(double value);
2711
+ DUCKDB_API static bool StringIsValid(const char *str, idx_t length);
2690
2712
  static bool StringIsValid(const string &str) {
2691
2713
  return StringIsValid(str.c_str(), str.size());
2692
2714
  }
@@ -2698,13 +2720,13 @@ public:
2698
2720
 
2699
2721
  //! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
2700
2722
  //! 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);
2723
+ DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
2702
2724
 
2703
2725
  friend std::ostream &operator<<(std::ostream &out, const Value &val) {
2704
2726
  out << val.ToString();
2705
2727
  return out;
2706
2728
  }
2707
- void Print() const;
2729
+ DUCKDB_API void Print() const;
2708
2730
 
2709
2731
  private:
2710
2732
  //! The logical of the value
@@ -3283,69 +3305,69 @@ class Vector {
3283
3305
 
3284
3306
  public:
3285
3307
  //! Create a vector that references the other vector
3286
- explicit Vector(Vector &other);
3308
+ DUCKDB_API explicit Vector(Vector &other);
3287
3309
  //! Create a vector that slices another vector
3288
- explicit Vector(Vector &other, const SelectionVector &sel, idx_t count);
3310
+ DUCKDB_API explicit Vector(Vector &other, const SelectionVector &sel, idx_t count);
3289
3311
  //! Create a vector that slices another vector starting from a specific offset
3290
- explicit Vector(Vector &other, idx_t offset);
3312
+ DUCKDB_API explicit Vector(Vector &other, idx_t offset);
3291
3313
  //! Create a vector of size one holding the passed on value
3292
- explicit Vector(const Value &value);
3314
+ DUCKDB_API explicit Vector(const Value &value);
3293
3315
  //! Create a vector of size tuple_count (non-standard)
3294
- explicit Vector(LogicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3316
+ DUCKDB_API explicit Vector(LogicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3295
3317
  //! Create an empty standard vector with a type, equivalent to calling Vector(type, true, false)
3296
- explicit Vector(const VectorCache &cache);
3318
+ DUCKDB_API explicit Vector(const VectorCache &cache);
3297
3319
  //! Create a non-owning vector that references the specified data
3298
- Vector(LogicalType type, data_ptr_t dataptr);
3320
+ DUCKDB_API Vector(LogicalType type, data_ptr_t dataptr);
3299
3321
  //! Create an owning vector that holds at most STANDARD_VECTOR_SIZE entries.
3300
3322
  /*!
3301
3323
  Create a new vector
3302
3324
  If create_data is true, the vector will be an owning empty vector.
3303
3325
  If zero_data is true, the allocated data will be zero-initialized.
3304
3326
  */
3305
- Vector(LogicalType type, bool create_data, bool zero_data, idx_t capacity = STANDARD_VECTOR_SIZE);
3327
+ DUCKDB_API Vector(LogicalType type, bool create_data, bool zero_data, idx_t capacity = STANDARD_VECTOR_SIZE);
3306
3328
  // implicit copying of Vectors is not allowed
3307
- Vector(const Vector &) = delete;
3329
+ DUCKDB_API Vector(const Vector &) = delete;
3308
3330
  // but moving of vectors is allowed
3309
- Vector(Vector &&other) noexcept;
3331
+ DUCKDB_API Vector(Vector &&other) noexcept;
3310
3332
 
3311
3333
  public:
3312
3334
  //! Create a vector that references the specified value.
3313
- void Reference(const Value &value);
3335
+ DUCKDB_API void Reference(const Value &value);
3314
3336
  //! Causes this vector to reference the data held by the other vector.
3315
3337
  //! The type of the "other" vector should match the type of this vector
3316
- void Reference(Vector &other);
3338
+ DUCKDB_API void Reference(Vector &other);
3317
3339
  //! Reinterpret the data of the other vector as the type of this vector
3318
3340
  //! Note that this takes the data of the other vector as-is and places it in this vector
3319
3341
  //! Without changing the type of this vector
3320
- void Reinterpret(Vector &other);
3342
+ DUCKDB_API void Reinterpret(Vector &other);
3321
3343
 
3322
3344
  //! Causes this vector to reference the data held by the other vector, changes the type if required.
3323
- void ReferenceAndSetType(Vector &other);
3345
+ DUCKDB_API void ReferenceAndSetType(Vector &other);
3324
3346
 
3325
3347
  //! Resets a vector from a vector cache.
3326
3348
  //! This turns the vector back into an empty FlatVector with STANDARD_VECTOR_SIZE entries.
3327
3349
  //! The VectorCache is used so this can be done without requiring any allocations.
3328
- void ResetFromCache(const VectorCache &cache);
3350
+ DUCKDB_API void ResetFromCache(const VectorCache &cache);
3329
3351
 
3330
3352
  //! Creates a reference to a slice of the other vector
3331
- void Slice(Vector &other, idx_t offset);
3353
+ DUCKDB_API void Slice(Vector &other, idx_t offset);
3332
3354
  //! Creates a reference to a slice of the other vector
3333
- void Slice(Vector &other, const SelectionVector &sel, idx_t count);
3355
+ DUCKDB_API void Slice(Vector &other, const SelectionVector &sel, idx_t count);
3334
3356
  //! Turns the vector into a dictionary vector with the specified dictionary
3335
- void Slice(const SelectionVector &sel, idx_t count);
3357
+ DUCKDB_API void Slice(const SelectionVector &sel, idx_t count);
3336
3358
  //! 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);
3359
+ DUCKDB_API void Slice(const SelectionVector &sel, idx_t count, SelCache &cache);
3338
3360
 
3339
3361
  //! Creates the data of this vector with the specified type. Any data that
3340
3362
  //! is currently in the vector is destroyed.
3341
- void Initialize(bool zero_data = false, idx_t capacity = STANDARD_VECTOR_SIZE);
3363
+ DUCKDB_API void Initialize(bool zero_data = false, idx_t capacity = STANDARD_VECTOR_SIZE);
3342
3364
 
3343
3365
  //! Converts this Vector to a printable string representation
3344
- string ToString(idx_t count) const;
3345
- void Print(idx_t count);
3366
+ DUCKDB_API string ToString(idx_t count) const;
3367
+ DUCKDB_API void Print(idx_t count);
3346
3368
 
3347
- string ToString() const;
3348
- void Print();
3369
+ DUCKDB_API string ToString() const;
3370
+ DUCKDB_API void Print();
3349
3371
 
3350
3372
  //! Flatten the vector, removing any compression and turning it into a FLAT_VECTOR
3351
3373
  DUCKDB_API void Normalify(idx_t count);
@@ -3354,31 +3376,31 @@ public:
3354
3376
  DUCKDB_API void Orrify(idx_t count, VectorData &data);
3355
3377
 
3356
3378
  //! Turn the vector into a sequence vector
3357
- void Sequence(int64_t start, int64_t increment);
3379
+ DUCKDB_API void Sequence(int64_t start, int64_t increment);
3358
3380
 
3359
3381
  //! Verify that the Vector is in a consistent, not corrupt state. DEBUG
3360
3382
  //! 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);
3383
+ DUCKDB_API void Verify(idx_t count);
3384
+ DUCKDB_API void Verify(const SelectionVector &sel, idx_t count);
3385
+ DUCKDB_API void UTFVerify(idx_t count);
3386
+ DUCKDB_API void UTFVerify(const SelectionVector &sel, idx_t count);
3365
3387
 
3366
3388
  //! Returns the [index] element of the Vector as a Value.
3367
- Value GetValue(idx_t index) const;
3389
+ DUCKDB_API Value GetValue(idx_t index) const;
3368
3390
  //! Sets the [index] element of the Vector to the specified Value.
3369
- void SetValue(idx_t index, const Value &val);
3391
+ DUCKDB_API void SetValue(idx_t index, const Value &val);
3370
3392
 
3371
- void SetAuxiliary(buffer_ptr<VectorBuffer> new_buffer) {
3393
+ inline void SetAuxiliary(buffer_ptr<VectorBuffer> new_buffer) {
3372
3394
  auxiliary = std::move(new_buffer);
3373
3395
  };
3374
3396
 
3375
3397
  //! This functions resizes the vector
3376
- void Resize(idx_t cur_size, idx_t new_size);
3398
+ DUCKDB_API void Resize(idx_t cur_size, idx_t new_size);
3377
3399
 
3378
3400
  //! Serializes a Vector to a stand-alone binary blob
3379
- void Serialize(idx_t count, Serializer &serializer);
3401
+ DUCKDB_API void Serialize(idx_t count, Serializer &serializer);
3380
3402
  //! Deserializes a blob back into a Vector
3381
- void Deserialize(idx_t count, Deserializer &source);
3403
+ DUCKDB_API void Deserialize(idx_t count, Deserializer &source);
3382
3404
 
3383
3405
  // Getters
3384
3406
  inline VectorType GetVectorType() const {
@@ -3391,11 +3413,11 @@ public:
3391
3413
  return data;
3392
3414
  }
3393
3415
 
3394
- buffer_ptr<VectorBuffer> GetAuxiliary() {
3416
+ inline buffer_ptr<VectorBuffer> GetAuxiliary() {
3395
3417
  return auxiliary;
3396
3418
  }
3397
3419
 
3398
- buffer_ptr<VectorBuffer> GetBuffer() {
3420
+ inline buffer_ptr<VectorBuffer> GetBuffer() {
3399
3421
  return buffer;
3400
3422
  }
3401
3423
 
@@ -3646,27 +3668,27 @@ class VectorCache;
3646
3668
  class DataChunk {
3647
3669
  public:
3648
3670
  //! Creates an empty DataChunk
3649
- DataChunk();
3650
- ~DataChunk();
3671
+ DUCKDB_API DataChunk();
3672
+ DUCKDB_API ~DataChunk();
3651
3673
 
3652
3674
  //! The vectors owned by the DataChunk.
3653
3675
  vector<Vector> data;
3654
3676
 
3655
3677
  public:
3656
- DUCKDB_API idx_t size() const {
3678
+ inline idx_t size() const { // NOLINT
3657
3679
  return count;
3658
3680
  }
3659
- DUCKDB_API idx_t ColumnCount() const {
3681
+ inline idx_t ColumnCount() const {
3660
3682
  return data.size();
3661
3683
  }
3662
- void SetCardinality(idx_t count_p) {
3684
+ inline void SetCardinality(idx_t count_p) {
3663
3685
  D_ASSERT(count_p <= capacity);
3664
3686
  this->count = count_p;
3665
3687
  }
3666
- void SetCardinality(const DataChunk &other) {
3688
+ inline void SetCardinality(const DataChunk &other) {
3667
3689
  this->count = other.size();
3668
3690
  }
3669
- void SetCapacity(const DataChunk &other) {
3691
+ inline void SetCapacity(const DataChunk &other) {
3670
3692
  this->capacity = other.capacity;
3671
3693
  }
3672
3694
 
@@ -3682,9 +3704,9 @@ public:
3682
3704
  //! This will create one vector of the specified type for each LogicalType in the
3683
3705
  //! types list. The vector will be referencing vector to the data owned by
3684
3706
  //! the DataChunk.
3685
- void Initialize(const vector<LogicalType> &types);
3707
+ DUCKDB_API void Initialize(const vector<LogicalType> &types);
3686
3708
  //! 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);
3709
+ DUCKDB_API void InitializeEmpty(const vector<LogicalType> &types);
3688
3710
  //! Append the other DataChunk to this one. The column count and types of
3689
3711
  //! the two DataChunks have to match exactly. Throws an exception if there
3690
3712
  //! is not enough space in the chunk and resize is not allowed.
@@ -5422,7 +5444,7 @@ public:
5422
5444
  }
5423
5445
 
5424
5446
  //! The location in the query (if any)
5425
- idx_t query_location = INVALID_INDEX;
5447
+ idx_t query_location = DConstants::INVALID_INDEX;
5426
5448
 
5427
5449
  public:
5428
5450
  bool IsAggregate() const override;
@@ -5491,11 +5513,8 @@ namespace duckdb {
5491
5513
  //! A column of a table.
5492
5514
  class ColumnDefinition {
5493
5515
  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
- }
5516
+ DUCKDB_API ColumnDefinition(string name, LogicalType type);
5517
+ DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression> default_value);
5499
5518
 
5500
5519
  //! The name of the entry
5501
5520
  string name;
@@ -5509,10 +5528,10 @@ public:
5509
5528
  CompressionType compression_type = CompressionType::COMPRESSION_AUTO;
5510
5529
 
5511
5530
  public:
5512
- ColumnDefinition Copy() const;
5531
+ DUCKDB_API ColumnDefinition Copy() const;
5513
5532
 
5514
- void Serialize(Serializer &serializer) const;
5515
- static ColumnDefinition Deserialize(Deserializer &source);
5533
+ DUCKDB_API void Serialize(Serializer &serializer) const;
5534
+ DUCKDB_API static ColumnDefinition Deserialize(Deserializer &source);
5516
5535
  };
5517
5536
 
5518
5537
  } // namespace duckdb
@@ -5538,24 +5557,11 @@ class TableFunction;
5538
5557
  struct PragmaInfo;
5539
5558
 
5540
5559
  struct FunctionData {
5541
- virtual ~FunctionData() {
5542
- }
5560
+ DUCKDB_API virtual ~FunctionData();
5543
5561
 
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
- }
5562
+ DUCKDB_API virtual unique_ptr<FunctionData> Copy();
5563
+ DUCKDB_API virtual bool Equals(FunctionData &other);
5564
+ DUCKDB_API static bool Equals(FunctionData *left, FunctionData *right);
5559
5565
  };
5560
5566
 
5561
5567
  struct TableFunctionData : public FunctionData {
@@ -5571,10 +5577,8 @@ struct FunctionParameters {
5571
5577
  //! Function is the base class used for any type of function (scalar, aggregate or simple function)
5572
5578
  class Function {
5573
5579
  public:
5574
- explicit Function(string name) : name(name) {
5575
- }
5576
- virtual ~Function() {
5577
- }
5580
+ DUCKDB_API explicit Function(string name);
5581
+ DUCKDB_API virtual ~Function();
5578
5582
 
5579
5583
  //! The name of the function
5580
5584
  string name;
@@ -5590,35 +5594,33 @@ public:
5590
5594
  const unordered_map<string, LogicalType> &named_parameters);
5591
5595
 
5592
5596
  //! 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);
5597
+ //! returns DConstants::INVALID_INDEX and sets error if none could be found
5598
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5599
+ vector<LogicalType> &arguments, string &error);
5600
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5601
+ vector<unique_ptr<Expression>> &arguments, string &error);
5598
5602
  //! 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);
5603
+ //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
5604
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5605
+ vector<LogicalType> &arguments, string &error);
5606
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5607
+ vector<unique_ptr<Expression>> &arguments, string &error);
5604
5608
  //! 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);
5609
+ //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
5610
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5611
+ vector<LogicalType> &arguments, string &error);
5612
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5613
+ vector<unique_ptr<Expression>> &arguments, string &error);
5610
5614
  //! 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);
5615
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<PragmaFunction> &functions, PragmaInfo &info,
5616
+ string &error);
5612
5617
  };
5613
5618
 
5614
5619
  class SimpleFunction : public Function {
5615
5620
  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
- }
5621
+ DUCKDB_API SimpleFunction(string name, vector<LogicalType> arguments,
5622
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5623
+ DUCKDB_API ~SimpleFunction() override;
5622
5624
 
5623
5625
  //! The set of arguments of the function
5624
5626
  vector<LogicalType> arguments;
@@ -5627,50 +5629,34 @@ public:
5627
5629
  LogicalType varargs;
5628
5630
 
5629
5631
  public:
5630
- virtual string ToString() {
5631
- return Function::CallToString(name, arguments);
5632
- }
5632
+ DUCKDB_API virtual string ToString();
5633
5633
 
5634
- bool HasVarArgs() const {
5635
- return varargs.id() != LogicalTypeId::INVALID;
5636
- }
5634
+ DUCKDB_API bool HasVarArgs() const;
5637
5635
  };
5638
5636
 
5639
5637
  class SimpleNamedParameterFunction : public SimpleFunction {
5640
5638
  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
- }
5639
+ DUCKDB_API SimpleNamedParameterFunction(string name, vector<LogicalType> arguments,
5640
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5641
+ DUCKDB_API ~SimpleNamedParameterFunction() override;
5647
5642
 
5648
5643
  //! The named parameters of the function
5649
5644
  unordered_map<string, LogicalType> named_parameters;
5650
5645
 
5651
5646
  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
- }
5647
+ DUCKDB_API string ToString() override;
5648
+ DUCKDB_API bool HasNamedParameters();
5659
5649
 
5660
- void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5661
- unordered_map<string, Value> &named_parameters,
5662
- vector<unique_ptr<ParsedExpression>> &children);
5650
+ DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5651
+ unordered_map<string, Value> &named_parameters,
5652
+ vector<unique_ptr<ParsedExpression>> &children);
5663
5653
  };
5664
5654
 
5665
5655
  class BaseScalarFunction : public SimpleFunction {
5666
5656
  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
- }
5657
+ DUCKDB_API BaseScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
5658
+ bool has_side_effects, LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5659
+ DUCKDB_API ~BaseScalarFunction() override;
5674
5660
 
5675
5661
  //! Return type of the function
5676
5662
  LogicalType return_type;
@@ -5679,14 +5665,12 @@ public:
5679
5665
  bool has_side_effects;
5680
5666
 
5681
5667
  public:
5682
- hash_t Hash() const;
5668
+ DUCKDB_API hash_t Hash() const;
5683
5669
 
5684
5670
  //! Cast a set of expressions to the arguments of this function
5685
- void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
5671
+ DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
5686
5672
 
5687
- string ToString() override {
5688
- return Function::CallToString(name, arguments, return_type);
5689
- }
5673
+ DUCKDB_API string ToString() override;
5690
5674
  };
5691
5675
 
5692
5676
  class BuiltinFunctions {
@@ -6014,8 +5998,9 @@ public:
6014
5998
  static constexpr const int32_t MONTHS_PER_YEAR = 12;
6015
5999
  static constexpr const int32_t MONTHS_PER_QUARTER = 3;
6016
6000
  static constexpr const int32_t DAYS_PER_WEEK = 7;
6017
- static constexpr const int64_t DAYS_PER_MONTH =
6018
- 30; // only used for interval comparison/ordering purposes, in which case a month counts as 30 days
6001
+ //! only used for interval comparison/ordering purposes, in which case a month counts as 30 days
6002
+ static constexpr const int64_t DAYS_PER_MONTH = 30;
6003
+ static constexpr const int64_t DAYS_PER_YEAR = 365;
6019
6004
  static constexpr const int64_t MSECS_PER_SEC = 1000;
6020
6005
  static constexpr const int32_t SECS_PER_MINUTE = 60;
6021
6006
  static constexpr const int32_t MINS_PER_HOUR = 60;
@@ -6049,7 +6034,7 @@ public:
6049
6034
  static string ToString(const interval_t &val);
6050
6035
 
6051
6036
  //! Convert milliseconds to a normalised interval
6052
- static interval_t FromMicro(int64_t micros);
6037
+ DUCKDB_API static interval_t FromMicro(int64_t micros);
6053
6038
 
6054
6039
  //! Get Interval in milliseconds
6055
6040
  static int64_t GetMilli(const interval_t &val);
@@ -6066,6 +6051,12 @@ public:
6066
6051
  //! Returns the exact difference between two timestamps (days and seconds)
6067
6052
  static interval_t GetDifference(timestamp_t timestamp_1, timestamp_t timestamp_2);
6068
6053
 
6054
+ //! Add an interval to a date
6055
+ static date_t Add(date_t left, interval_t right);
6056
+ //! Add an interval to a time. In case the time overflows or underflows, modify the date by the overflow.
6057
+ //! For example if we go from 23:00 to 02:00, we add a day to the date
6058
+ static dtime_t Add(dtime_t left, interval_t right, date_t &date);
6059
+
6069
6060
  //! Comparison operators
6070
6061
  static bool Equals(interval_t left, interval_t right);
6071
6062
  static bool GreaterThan(interval_t left, interval_t right);
@@ -6401,23 +6392,17 @@ typedef void (*dependency_function_t)(BoundFunctionExpression &expr, unordered_s
6401
6392
 
6402
6393
  class ScalarFunction : public BaseScalarFunction {
6403
6394
  public:
6404
- ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6405
- bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6406
- dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6407
- init_local_state_t init_local_state = nullptr,
6408
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
6409
- : BaseScalarFunction(name, arguments, return_type, has_side_effects, varargs), function(function), bind(bind),
6410
- init_local_state(init_local_state), dependency(dependency), statistics(statistics) {
6411
- }
6395
+ DUCKDB_API ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
6396
+ scalar_function_t function, bool has_side_effects = false,
6397
+ bind_scalar_function_t bind = nullptr, dependency_function_t dependency = nullptr,
6398
+ function_statistics_t statistics = nullptr, init_local_state_t init_local_state = nullptr,
6399
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
6412
6400
 
6413
- ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6414
- bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6415
- dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6416
- init_local_state_t init_local_state = nullptr,
6417
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
6418
- : ScalarFunction(string(), arguments, return_type, function, has_side_effects, bind, dependency, statistics,
6419
- init_local_state, varargs) {
6420
- }
6401
+ DUCKDB_API ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6402
+ bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6403
+ dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6404
+ init_local_state_t init_local_state = nullptr,
6405
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
6421
6406
 
6422
6407
  //! The main scalar function to execute
6423
6408
  scalar_function_t function;
@@ -6425,78 +6410,35 @@ public:
6425
6410
  bind_scalar_function_t bind;
6426
6411
  //! Init thread local state for the function (if any)
6427
6412
  init_local_state_t init_local_state;
6428
- // The dependency function (if any)
6413
+ //! The dependency function (if any)
6429
6414
  dependency_function_t dependency;
6430
6415
  //! The statistics propagation function (if any)
6431
6416
  function_statistics_t statistics;
6432
6417
 
6433
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context, const string &schema,
6434
- const string &name,
6435
- vector<unique_ptr<Expression>> children,
6436
- string &error, bool is_operator = false);
6437
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6438
- ScalarFunctionCatalogEntry &function,
6439
- vector<unique_ptr<Expression>> children,
6440
- string &error, bool is_operator = false);
6441
-
6442
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context, ScalarFunction bound_function,
6443
- vector<unique_ptr<Expression>> children,
6444
- bool is_operator = false);
6418
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6419
+ const string &schema, const string &name,
6420
+ vector<unique_ptr<Expression>> children,
6421
+ string &error, bool is_operator = false);
6422
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6423
+ ScalarFunctionCatalogEntry &function,
6424
+ vector<unique_ptr<Expression>> children,
6425
+ string &error, bool is_operator = false);
6445
6426
 
6446
- bool operator==(const ScalarFunction &rhs) const {
6447
- return CompareScalarFunctionT(rhs.function) && bind == rhs.bind && dependency == rhs.dependency &&
6448
- statistics == rhs.statistics;
6449
- }
6450
- bool operator!=(const ScalarFunction &rhs) const {
6451
- return !(*this == rhs);
6452
- }
6427
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6428
+ ScalarFunction bound_function,
6429
+ vector<unique_ptr<Expression>> children,
6430
+ bool is_operator = false);
6453
6431
 
6454
- bool Equal(const ScalarFunction &rhs) const {
6455
- // number of types
6456
- if (this->arguments.size() != rhs.arguments.size()) {
6457
- return false;
6458
- }
6459
- // argument types
6460
- for (idx_t i = 0; i < this->arguments.size(); ++i) {
6461
- if (this->arguments[i] != rhs.arguments[i]) {
6462
- return false;
6463
- }
6464
- }
6465
- // return type
6466
- if (this->return_type != rhs.return_type) {
6467
- return false;
6468
- }
6469
- // varargs
6470
- if (this->varargs != rhs.varargs) {
6471
- return false;
6472
- }
6432
+ DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
6433
+ DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
6473
6434
 
6474
- return true; // they are equal
6475
- }
6435
+ DUCKDB_API bool Equal(const ScalarFunction &rhs) const;
6476
6436
 
6477
6437
  private:
6478
- bool CompareScalarFunctionT(const scalar_function_t other) const {
6479
- typedef void(scalar_function_ptr_t)(DataChunk &, ExpressionState &, Vector &);
6480
-
6481
- auto func_ptr = (scalar_function_ptr_t **)function.template target<scalar_function_ptr_t *>();
6482
- auto other_ptr = (scalar_function_ptr_t **)other.template target<scalar_function_ptr_t *>();
6483
-
6484
- // Case the functions were created from lambdas the target will return a nullptr
6485
- if (!func_ptr && !other_ptr) {
6486
- return true;
6487
- }
6488
- if (func_ptr == nullptr || other_ptr == nullptr) {
6489
- // scalar_function_t (std::functions) from lambdas cannot be compared
6490
- return false;
6491
- }
6492
- return ((size_t)*func_ptr == (size_t)*other_ptr);
6493
- }
6438
+ bool CompareScalarFunctionT(const scalar_function_t &other) const;
6494
6439
 
6495
6440
  public:
6496
- static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result) {
6497
- D_ASSERT(input.ColumnCount() >= 1);
6498
- result.Reference(input.data[0]);
6499
- }
6441
+ DUCKDB_API static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result);
6500
6442
 
6501
6443
  template <class TA, class TR, class OP>
6502
6444
  static void UnaryFunction(DataChunk &input, ExpressionState &state, Vector &result) {
@@ -6947,12 +6889,12 @@ public:
6947
6889
 
6948
6890
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
6949
6891
  static void UnaryWindow(Vector &input, FunctionData *bind_data, data_ptr_t state, const FrameBounds &frame,
6950
- const FrameBounds &prev, Vector &result, idx_t rid) {
6892
+ const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
6951
6893
 
6952
- auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - MinValue(frame.first, prev.first);
6894
+ auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
6953
6895
  const auto &ivalid = FlatVector::Validity(input);
6954
6896
  OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ivalid, bind_data, (STATE *)state, frame, prev,
6955
- result, rid);
6897
+ result, rid, bias);
6956
6898
  }
6957
6899
 
6958
6900
  template <class STATE_TYPE, class OP>
@@ -7052,7 +6994,12 @@ enum class OrderByNullType : uint8_t { INVALID = 0, ORDER_DEFAULT = 1, NULLS_FIR
7052
6994
 
7053
6995
  namespace duckdb {
7054
6996
 
7055
- enum ResultModifierType : uint8_t { LIMIT_MODIFIER = 1, ORDER_MODIFIER = 2, DISTINCT_MODIFIER = 3 };
6997
+ enum ResultModifierType : uint8_t {
6998
+ LIMIT_MODIFIER = 1,
6999
+ ORDER_MODIFIER = 2,
7000
+ DISTINCT_MODIFIER = 3,
7001
+ LIMIT_PERCENT_MODIFIER = 4
7002
+ };
7056
7003
 
7057
7004
  //! A ResultModifier
7058
7005
  class ResultModifier {
@@ -7142,6 +7089,23 @@ public:
7142
7089
  static unique_ptr<ResultModifier> Deserialize(Deserializer &source);
7143
7090
  };
7144
7091
 
7092
+ class LimitPercentModifier : public ResultModifier {
7093
+ public:
7094
+ LimitPercentModifier() : ResultModifier(ResultModifierType::LIMIT_PERCENT_MODIFIER) {
7095
+ }
7096
+
7097
+ //! LIMIT %
7098
+ unique_ptr<ParsedExpression> limit;
7099
+ //! OFFSET
7100
+ unique_ptr<ParsedExpression> offset;
7101
+
7102
+ public:
7103
+ bool Equals(const ResultModifier *other) const override;
7104
+ unique_ptr<ResultModifier> Copy() override;
7105
+ void Serialize(Serializer &serializer) override;
7106
+ static unique_ptr<ResultModifier> Deserialize(Deserializer &source);
7107
+ };
7108
+
7145
7109
  } // namespace duckdb
7146
7110
 
7147
7111
  //===----------------------------------------------------------------------===//
@@ -7336,7 +7300,7 @@ class SQLStatement;
7336
7300
 
7337
7301
  class QueryErrorContext {
7338
7302
  public:
7339
- explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = INVALID_INDEX)
7303
+ explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = DConstants::INVALID_INDEX)
7340
7304
  : statement(statement_), query_location(query_location_) {
7341
7305
  }
7342
7306
 
@@ -7381,6 +7345,7 @@ struct CreateViewInfo;
7381
7345
  struct CreateSequenceInfo;
7382
7346
  struct CreateCollationInfo;
7383
7347
  struct CreateTypeInfo;
7348
+ struct CreateTableInfo;
7384
7349
 
7385
7350
  class ClientContext;
7386
7351
  class Transaction;
@@ -7403,7 +7368,7 @@ struct CatalogEntryLookup {
7403
7368
  SchemaCatalogEntry *schema;
7404
7369
  CatalogEntry *entry;
7405
7370
 
7406
- bool Found() const {
7371
+ DUCKDB_API bool Found() const {
7407
7372
  return entry;
7408
7373
  }
7409
7374
  };
@@ -7417,11 +7382,11 @@ struct SimilarCatalogEntry {
7417
7382
  //! The schema of the entry.
7418
7383
  SchemaCatalogEntry *schema;
7419
7384
 
7420
- bool Found() const {
7385
+ DUCKDB_API bool Found() const {
7421
7386
  return !name.empty();
7422
7387
  }
7423
7388
 
7424
- string GetQualifiedName() const;
7389
+ DUCKDB_API string GetQualifiedName() const;
7425
7390
  };
7426
7391
 
7427
7392
  //! The Catalog object represents the catalog of the database.
@@ -7441,79 +7406,93 @@ public:
7441
7406
 
7442
7407
  public:
7443
7408
  //! Get the ClientContext from the Catalog
7444
- static Catalog &GetCatalog(ClientContext &context);
7445
- static Catalog &GetCatalog(DatabaseInstance &db);
7409
+ DUCKDB_API static Catalog &GetCatalog(ClientContext &context);
7410
+ DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db);
7446
7411
 
7447
- DependencyManager &GetDependencyManager() {
7412
+ DUCKDB_API DependencyManager &GetDependencyManager() {
7448
7413
  return *dependency_manager;
7449
7414
  }
7450
7415
 
7451
7416
  //! Returns the current version of the catalog (incremented whenever anything changes, not stored between restarts)
7452
- idx_t GetCatalogVersion();
7417
+ DUCKDB_API idx_t GetCatalogVersion();
7453
7418
  //! Trigger a modification in the catalog, increasing the catalog version and returning the previous version
7454
- idx_t ModifyCatalog();
7419
+ DUCKDB_API idx_t ModifyCatalog();
7455
7420
 
7456
7421
  //! Creates a schema in the catalog.
7457
- CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
7422
+ DUCKDB_API CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
7458
7423
  //! Creates a table in the catalog.
7459
- CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
7424
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
7425
+ //! Creates a table in the catalog.
7426
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, unique_ptr<CreateTableInfo> info);
7460
7427
  //! Create a table function in the catalog
7461
- CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
7428
+ DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
7462
7429
  //! Create a copy function in the catalog
7463
- CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
7430
+ DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
7464
7431
  //! Create a pragma function in the catalog
7465
- CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
7432
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
7466
7433
  //! Create a scalar or aggregate function in the catalog
7467
- CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
7434
+ DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
7468
7435
  //! Creates a table in the catalog.
7469
- CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
7436
+ DUCKDB_API CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
7470
7437
  //! Creates a table in the catalog.
7471
- CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
7438
+ DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
7472
7439
  //! Creates a Enum in the catalog.
7473
- CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
7440
+ DUCKDB_API CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
7474
7441
  //! Creates a collation in the catalog
7475
- CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
7442
+ DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
7476
7443
 
7477
7444
  //! Creates a table in the catalog.
7478
- CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema, BoundCreateTableInfo *info);
7445
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema,
7446
+ BoundCreateTableInfo *info);
7479
7447
  //! Create a table function in the catalog
7480
- CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
7481
- CreateTableFunctionInfo *info);
7448
+ DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
7449
+ CreateTableFunctionInfo *info);
7482
7450
  //! Create a copy function in the catalog
7483
- CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateCopyFunctionInfo *info);
7451
+ DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema,
7452
+ CreateCopyFunctionInfo *info);
7484
7453
  //! Create a pragma function in the catalog
7485
- CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
7486
- CreatePragmaFunctionInfo *info);
7454
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
7455
+ CreatePragmaFunctionInfo *info);
7487
7456
  //! Create a scalar or aggregate function in the catalog
7488
- CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info);
7457
+ DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema,
7458
+ CreateFunctionInfo *info);
7489
7459
  //! Creates a table in the catalog.
7490
- CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
7460
+ DUCKDB_API CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
7491
7461
  //! Creates a table in the catalog.
7492
- CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema, CreateSequenceInfo *info);
7462
+ DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema,
7463
+ CreateSequenceInfo *info);
7493
7464
  //! Creates a enum in the catalog.
7494
- CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
7465
+ DUCKDB_API CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
7495
7466
  //! Creates a collation in the catalog
7496
- CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema, CreateCollationInfo *info);
7467
+ DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema,
7468
+ CreateCollationInfo *info);
7497
7469
 
7498
7470
  //! Drops an entry from the catalog
7499
- void DropEntry(ClientContext &context, DropInfo *info);
7471
+ DUCKDB_API void DropEntry(ClientContext &context, DropInfo *info);
7500
7472
 
7501
7473
  //! Returns the schema object with the specified name, or throws an exception if it does not exist
7502
- SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA, bool if_exists = false,
7503
- QueryErrorContext error_context = QueryErrorContext());
7474
+ DUCKDB_API SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA,
7475
+ bool if_exists = false,
7476
+ QueryErrorContext error_context = QueryErrorContext());
7504
7477
  //! Scans all the schemas in the system one-by-one, invoking the callback for each entry
7505
- void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
7478
+ DUCKDB_API void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
7506
7479
  //! Gets the "schema.name" entry of the specified type, if if_exists=true returns nullptr if entry does not exist,
7507
7480
  //! otherwise an exception is thrown
7508
- CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema, const string &name,
7509
- bool if_exists = false, QueryErrorContext error_context = QueryErrorContext());
7481
+ DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema,
7482
+ const string &name, bool if_exists = false,
7483
+ QueryErrorContext error_context = QueryErrorContext());
7510
7484
 
7511
7485
  template <class T>
7512
7486
  T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
7513
7487
  QueryErrorContext error_context = QueryErrorContext());
7514
7488
 
7489
+ //! Append a scalar or aggregate function to the catalog
7490
+ DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
7491
+ //! Append a scalar or aggregate function to the catalog
7492
+ DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info);
7493
+
7515
7494
  //! Alter an existing entry in the catalog.
7516
- void Alter(ClientContext &context, AlterInfo *info);
7495
+ DUCKDB_API void Alter(ClientContext &context, AlterInfo *info);
7517
7496
 
7518
7497
  private:
7519
7498
  //! The catalog version, incremented whenever anything changes in the catalog
@@ -7537,26 +7516,30 @@ private:
7537
7516
  };
7538
7517
 
7539
7518
  template <>
7540
- TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7541
- bool if_exists, QueryErrorContext error_context);
7519
+ DUCKDB_API TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7520
+ bool if_exists, QueryErrorContext error_context);
7542
7521
  template <>
7543
- SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7544
- bool if_exists, QueryErrorContext error_context);
7522
+ DUCKDB_API SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7523
+ const string &name, bool if_exists, QueryErrorContext error_context);
7545
7524
  template <>
7546
- TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7547
- bool if_exists, QueryErrorContext error_context);
7525
+ DUCKDB_API TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7526
+ const string &name, bool if_exists,
7527
+ QueryErrorContext error_context);
7548
7528
  template <>
7549
- CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7550
- bool if_exists, QueryErrorContext error_context);
7529
+ DUCKDB_API CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7530
+ const string &name, bool if_exists,
7531
+ QueryErrorContext error_context);
7551
7532
  template <>
7552
- PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7553
- bool if_exists, QueryErrorContext error_context);
7533
+ DUCKDB_API PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7534
+ const string &name, bool if_exists,
7535
+ QueryErrorContext error_context);
7554
7536
  template <>
7555
- AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7556
- bool if_exists, QueryErrorContext error_context);
7537
+ DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7538
+ const string &name, bool if_exists,
7539
+ QueryErrorContext error_context);
7557
7540
  template <>
7558
- CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7559
- bool if_exists, QueryErrorContext error_context);
7541
+ DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7542
+ bool if_exists, QueryErrorContext error_context);
7560
7543
 
7561
7544
  } // namespace duckdb
7562
7545
 
@@ -7591,6 +7574,7 @@ enum class LogicalOperatorType : uint8_t {
7591
7574
  LOGICAL_COPY_TO_FILE = 10,
7592
7575
  LOGICAL_DISTINCT = 11,
7593
7576
  LOGICAL_SAMPLE = 12,
7577
+ LOGICAL_LIMIT_PERCENT = 13,
7594
7578
 
7595
7579
  // -----------------------------
7596
7580
  // Data sources
@@ -7921,7 +7905,7 @@ struct ColumnBinding {
7921
7905
  idx_t table_index;
7922
7906
  idx_t column_index;
7923
7907
 
7924
- ColumnBinding() : table_index(INVALID_INDEX), column_index(INVALID_INDEX) {
7908
+ ColumnBinding() : table_index(DConstants::INVALID_INDEX), column_index(DConstants::INVALID_INDEX) {
7925
7909
  }
7926
7910
  ColumnBinding(idx_t table, idx_t column) : table_index(table), column_index(column) {
7927
7911
  }
@@ -7975,7 +7959,7 @@ public:
7975
7959
 
7976
7960
  virtual string GetName() const;
7977
7961
  virtual string ParamsToString() const;
7978
- virtual string ToString(idx_t depth = 0) const;
7962
+ virtual string ToString() const;
7979
7963
  void Print();
7980
7964
  //! Debug method: verify that the integrity of expressions & child nodes are maintained
7981
7965
  virtual void Verify();
@@ -8082,6 +8066,20 @@ public:
8082
8066
  vector<unique_ptr<Expression>> target_distincts;
8083
8067
  };
8084
8068
 
8069
+ class BoundLimitPercentModifier : public BoundResultModifier {
8070
+ public:
8071
+ BoundLimitPercentModifier() : BoundResultModifier(ResultModifierType::LIMIT_PERCENT_MODIFIER) {
8072
+ }
8073
+ //! LIMIT %
8074
+ double limit_percent = 100.0;
8075
+ //! OFFSET
8076
+ int64_t offset_val = 0;
8077
+ //! Expression in case limit is not constant
8078
+ unique_ptr<Expression> limit;
8079
+ //! Expression in case limit is not constant
8080
+ unique_ptr<Expression> offset;
8081
+ };
8082
+
8085
8083
  } // namespace duckdb
8086
8084
 
8087
8085
 
@@ -8119,26 +8117,29 @@ typedef void (*aggregate_simple_update_t)(Vector inputs[], FunctionData *bind_da
8119
8117
  //! The type used for updating complex windowed aggregate functions (optional)
8120
8118
  typedef std::pair<idx_t, idx_t> FrameBounds;
8121
8119
  typedef void (*aggregate_window_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
8122
- const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t offset);
8120
+ const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid,
8121
+ idx_t bias);
8123
8122
 
8124
8123
  class AggregateFunction : public BaseScalarFunction {
8125
8124
  public:
8126
- AggregateFunction(const string &name, const vector<LogicalType> &arguments, const LogicalType &return_type,
8127
- aggregate_size_t state_size, aggregate_initialize_t initialize, aggregate_update_t update,
8128
- aggregate_combine_t combine, aggregate_finalize_t finalize,
8129
- aggregate_simple_update_t simple_update = nullptr, bind_aggregate_function_t bind = nullptr,
8130
- aggregate_destructor_t destructor = nullptr, aggregate_statistics_t statistics = nullptr,
8131
- aggregate_window_t window = nullptr)
8125
+ DUCKDB_API AggregateFunction(const string &name, const vector<LogicalType> &arguments,
8126
+ const LogicalType &return_type, aggregate_size_t state_size,
8127
+ aggregate_initialize_t initialize, aggregate_update_t update,
8128
+ aggregate_combine_t combine, aggregate_finalize_t finalize,
8129
+ aggregate_simple_update_t simple_update = nullptr,
8130
+ bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8131
+ aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8132
8132
  : BaseScalarFunction(name, arguments, return_type, false), state_size(state_size), initialize(initialize),
8133
8133
  update(update), combine(combine), finalize(finalize), simple_update(simple_update), window(window),
8134
8134
  bind(bind), destructor(destructor), statistics(statistics) {
8135
8135
  }
8136
8136
 
8137
- AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type, aggregate_size_t state_size,
8138
- aggregate_initialize_t initialize, aggregate_update_t update, aggregate_combine_t combine,
8139
- aggregate_finalize_t finalize, aggregate_simple_update_t simple_update = nullptr,
8140
- bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8141
- aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8137
+ DUCKDB_API AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type,
8138
+ aggregate_size_t state_size, aggregate_initialize_t initialize,
8139
+ aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize,
8140
+ aggregate_simple_update_t simple_update = nullptr,
8141
+ bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8142
+ aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8142
8143
  : AggregateFunction(string(), arguments, return_type, state_size, initialize, update, combine, finalize,
8143
8144
  simple_update, bind, destructor, statistics, window) {
8144
8145
  }
@@ -8166,23 +8167,23 @@ public:
8166
8167
  //! The statistics propagation function (may be null)
8167
8168
  aggregate_statistics_t statistics;
8168
8169
 
8169
- bool operator==(const AggregateFunction &rhs) const {
8170
+ DUCKDB_API bool operator==(const AggregateFunction &rhs) const {
8170
8171
  return state_size == rhs.state_size && initialize == rhs.initialize && update == rhs.update &&
8171
8172
  combine == rhs.combine && finalize == rhs.finalize && window == rhs.window;
8172
8173
  }
8173
- bool operator!=(const AggregateFunction &rhs) const {
8174
+ DUCKDB_API bool operator!=(const AggregateFunction &rhs) const {
8174
8175
  return !(*this == rhs);
8175
8176
  }
8176
8177
 
8177
- static unique_ptr<BoundAggregateExpression>
8178
+ DUCKDB_API static unique_ptr<BoundAggregateExpression>
8178
8179
  BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
8179
8180
  vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
8180
8181
  bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr);
8181
8182
 
8182
- static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
8183
- vector<unique_ptr<Expression>> &children,
8184
- unique_ptr<FunctionData> bind_info,
8185
- unique_ptr<BoundOrderModifier> order_bys);
8183
+ DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
8184
+ vector<unique_ptr<Expression>> &children,
8185
+ unique_ptr<FunctionData> bind_info,
8186
+ unique_ptr<BoundOrderModifier> order_bys);
8186
8187
 
8187
8188
  public:
8188
8189
  template <class STATE, class RESULT_TYPE, class OP>
@@ -8261,10 +8262,10 @@ public:
8261
8262
 
8262
8263
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
8263
8264
  static void UnaryWindow(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
8264
- const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid) {
8265
+ const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
8265
8266
  D_ASSERT(input_count == 1);
8266
8267
  AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], bind_data, state, frame, prev,
8267
- result, rid);
8268
+ result, rid, bias);
8268
8269
  }
8269
8270
 
8270
8271
  template <class STATE, class A_TYPE, class B_TYPE, class OP>
@@ -8585,7 +8586,7 @@ private:
8585
8586
  }
8586
8587
 
8587
8588
  template <typename T>
8588
- static bool TypesMatch(LogicalType sql_type) {
8589
+ static bool TypesMatch(const LogicalType &sql_type) {
8589
8590
  switch (sql_type.id()) {
8590
8591
  case LogicalTypeId::BOOLEAN:
8591
8592
  return std::is_same<T, bool>();
@@ -8598,13 +8599,16 @@ private:
8598
8599
  case LogicalTypeId::BIGINT:
8599
8600
  return std::is_same<T, int64_t>();
8600
8601
  case LogicalTypeId::DATE:
8602
+ case LogicalTypeId::DATE_TZ:
8601
8603
  return std::is_same<T, date_t>();
8602
8604
  case LogicalTypeId::TIME:
8605
+ case LogicalTypeId::TIME_TZ:
8603
8606
  return std::is_same<T, dtime_t>();
8604
8607
  case LogicalTypeId::TIMESTAMP:
8605
8608
  case LogicalTypeId::TIMESTAMP_MS:
8606
8609
  case LogicalTypeId::TIMESTAMP_NS:
8607
8610
  case LogicalTypeId::TIMESTAMP_SEC:
8611
+ case LogicalTypeId::TIMESTAMP_TZ:
8608
8612
  return std::is_same<T, timestamp_t>();
8609
8613
  case LogicalTypeId::FLOAT:
8610
8614
  return std::is_same<T, float>();
@@ -9457,11 +9461,13 @@ namespace duckdb {
9457
9461
  class Printer {
9458
9462
  public:
9459
9463
  //! Print the object to stderr
9460
- static void Print(const string &str);
9464
+ DUCKDB_API static void Print(const string &str);
9461
9465
  //! Prints Progress
9462
- static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9466
+ DUCKDB_API static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9463
9467
  //! Prints an empty line when progress bar is done
9464
- static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9468
+ DUCKDB_API static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9469
+ //! Whether or not we are printing to a terminal
9470
+ DUCKDB_API static bool IsTerminal();
9465
9471
  };
9466
9472
  } // namespace duckdb
9467
9473
 
@@ -9823,16 +9829,16 @@ namespace duckdb {
9823
9829
  */
9824
9830
  class StringUtil {
9825
9831
  public:
9826
- static bool CharacterIsSpace(char c) {
9832
+ DUCKDB_API static bool CharacterIsSpace(char c) {
9827
9833
  return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
9828
9834
  }
9829
- static bool CharacterIsNewline(char c) {
9835
+ DUCKDB_API static bool CharacterIsNewline(char c) {
9830
9836
  return c == '\n' || c == '\r';
9831
9837
  }
9832
- static bool CharacterIsDigit(char c) {
9838
+ DUCKDB_API static bool CharacterIsDigit(char c) {
9833
9839
  return c >= '0' && c <= '9';
9834
9840
  }
9835
- static char CharacterToLower(char c) {
9841
+ DUCKDB_API static char CharacterToLower(char c) {
9836
9842
  if (c >= 'A' && c <= 'Z') {
9837
9843
  return c - ('A' - 'a');
9838
9844
  }
@@ -9840,25 +9846,25 @@ public:
9840
9846
  }
9841
9847
 
9842
9848
  //! Returns true if the needle string exists in the haystack
9843
- static bool Contains(const string &haystack, const string &needle);
9849
+ DUCKDB_API static bool Contains(const string &haystack, const string &needle);
9844
9850
 
9845
9851
  //! Returns true if the target string starts with the given prefix
9846
- static bool StartsWith(string str, string prefix);
9852
+ DUCKDB_API static bool StartsWith(string str, string prefix);
9847
9853
 
9848
9854
  //! Returns true if the target string <b>ends</b> with the given suffix.
9849
- static bool EndsWith(const string &str, const string &suffix);
9855
+ DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
9850
9856
 
9851
9857
  //! Repeat a string multiple times
9852
- static string Repeat(const string &str, const idx_t n);
9858
+ DUCKDB_API static string Repeat(const string &str, const idx_t n);
9853
9859
 
9854
9860
  //! Split the input string based on newline char
9855
- static vector<string> Split(const string &str, char delimiter);
9861
+ DUCKDB_API static vector<string> Split(const string &str, char delimiter);
9856
9862
 
9857
9863
  //! Split the input string allong a quote. Note that any escaping is NOT supported.
9858
- static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
9864
+ DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
9859
9865
 
9860
9866
  //! Join multiple strings into one string. Components are concatenated by the given separator
9861
- static string Join(const vector<string> &input, const string &separator);
9867
+ DUCKDB_API static string Join(const vector<string> &input, const string &separator);
9862
9868
 
9863
9869
  //! Join multiple items of container with given size, transformed to string
9864
9870
  //! using function, into one string using the given separator
@@ -9882,13 +9888,13 @@ public:
9882
9888
  }
9883
9889
 
9884
9890
  //! Return a string that formats the give number of bytes
9885
- static string BytesToHumanReadableString(idx_t bytes);
9891
+ DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
9886
9892
 
9887
9893
  //! Convert a string to uppercase
9888
- static string Upper(const string &str);
9894
+ DUCKDB_API static string Upper(const string &str);
9889
9895
 
9890
9896
  //! Convert a string to lowercase
9891
- static string Lower(const string &str);
9897
+ DUCKDB_API static string Lower(const string &str);
9892
9898
 
9893
9899
  //! Format a string using printf semantics
9894
9900
  template <typename... Args>
@@ -9897,30 +9903,38 @@ public:
9897
9903
  }
9898
9904
 
9899
9905
  //! Split the input string into a vector of strings based on the split string
9900
- static vector<string> Split(const string &input, const string &split);
9906
+ DUCKDB_API static vector<string> Split(const string &input, const string &split);
9901
9907
 
9902
9908
  //! Remove the whitespace char in the left end of the string
9903
- static void LTrim(string &str);
9909
+ DUCKDB_API static void LTrim(string &str);
9904
9910
  //! Remove the whitespace char in the right end of the string
9905
- static void RTrim(string &str);
9911
+ DUCKDB_API static void RTrim(string &str);
9906
9912
  //! Remove the whitespace char in the left and right end of the string
9907
- static void Trim(string &str);
9913
+ DUCKDB_API static void Trim(string &str);
9908
9914
 
9909
- static string Replace(string source, const string &from, const string &to);
9915
+ DUCKDB_API static string Replace(string source, const string &from, const string &to);
9910
9916
 
9911
9917
  //! Get the levenshtein distance from two strings
9912
- static idx_t LevenshteinDistance(const string &s1, const string &s2);
9918
+ DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
9913
9919
 
9914
9920
  //! Get the top-n strings (sorted by the given score distance) from a set of scores.
9915
9921
  //! At least one entry is returned (if there is one).
9916
9922
  //! Strings are only returned if they have a score less than the threshold.
9917
- static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5, idx_t threshold = 5);
9923
+ DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
9924
+ idx_t threshold = 5);
9918
9925
  //! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
9919
9926
  //! with the given params.
9920
- static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
9921
- idx_t threshold = 5);
9922
- static string CandidatesMessage(const vector<string> &candidates, const string &candidate = "Candidate bindings");
9927
+ DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
9928
+ idx_t threshold = 5);
9929
+ DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
9930
+ const string &candidate = "Candidate bindings");
9931
+
9932
+ //! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
9933
+ //! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
9934
+ DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
9935
+ const string &message_prefix, idx_t n = 5);
9923
9936
  };
9937
+
9924
9938
  } // namespace duckdb
9925
9939
 
9926
9940
 
@@ -10033,6 +10047,7 @@ enum class OptimizerType : uint32_t {
10033
10047
  };
10034
10048
 
10035
10049
  string OptimizerTypeToString(OptimizerType type);
10050
+ OptimizerType OptimizerTypeFromString(const string &str);
10036
10051
 
10037
10052
  } // namespace duckdb
10038
10053
 
@@ -10061,6 +10076,29 @@ enum class WindowAggregationMode : uint32_t {
10061
10076
 
10062
10077
  } // namespace duckdb
10063
10078
 
10079
+ //===----------------------------------------------------------------------===//
10080
+ // DuckDB
10081
+ //
10082
+ // duckdb/common/enums/set_scope.hpp
10083
+ //
10084
+ //
10085
+ //===----------------------------------------------------------------------===//
10086
+
10087
+
10088
+
10089
+
10090
+
10091
+ namespace duckdb {
10092
+
10093
+ enum class SetScope : uint8_t {
10094
+ AUTOMATIC = 0,
10095
+ LOCAL = 1, /* unused */
10096
+ SESSION = 2,
10097
+ GLOBAL = 3
10098
+ };
10099
+
10100
+ } // namespace duckdb
10101
+
10064
10102
 
10065
10103
  namespace duckdb {
10066
10104
  class ClientContext;
@@ -10068,6 +10106,7 @@ class TableFunctionRef;
10068
10106
  class CompressionFunction;
10069
10107
 
10070
10108
  struct CompressionFunctionSet;
10109
+ struct DBConfig;
10071
10110
 
10072
10111
  enum class AccessMode : uint8_t { UNDEFINED = 0, AUTOMATIC = 1, READ_ONLY = 2, READ_WRITE = 3 };
10073
10112
 
@@ -10078,25 +10117,31 @@ enum class CheckpointAbort : uint8_t {
10078
10117
  DEBUG_ABORT_AFTER_FREE_LIST_WRITE = 3
10079
10118
  };
10080
10119
 
10081
- enum class ConfigurationOptionType : uint32_t {
10082
- INVALID = 0,
10083
- ACCESS_MODE,
10084
- DEFAULT_ORDER_TYPE,
10085
- DEFAULT_NULL_ORDER,
10086
- ENABLE_EXTERNAL_ACCESS,
10087
- ENABLE_OBJECT_CACHE,
10088
- MAXIMUM_MEMORY,
10089
- THREADS
10090
- };
10120
+ typedef void (*set_global_function_t)(DatabaseInstance *db, DBConfig &config, const Value &parameter);
10121
+ typedef void (*set_local_function_t)(ClientContext &context, const Value &parameter);
10122
+ typedef Value (*get_setting_function_t)(ClientContext &context);
10091
10123
 
10092
10124
  struct ConfigurationOption {
10093
- ConfigurationOptionType type;
10094
10125
  const char *name;
10095
10126
  const char *description;
10096
10127
  LogicalTypeId parameter_type;
10128
+ set_global_function_t set_global;
10129
+ set_local_function_t set_local;
10130
+ get_setting_function_t get_setting;
10131
+ };
10132
+
10133
+ typedef void (*set_option_callback_t)(ClientContext &context, SetScope scope, Value &parameter);
10134
+
10135
+ struct ExtensionOption {
10136
+ ExtensionOption(string description_p, LogicalType type_p, set_option_callback_t set_function_p)
10137
+ : description(move(description_p)), type(move(type_p)), set_function(set_function_p) {
10138
+ }
10139
+
10140
+ string description;
10141
+ LogicalType type;
10142
+ set_option_callback_t set_function;
10097
10143
  };
10098
10144
 
10099
- // this is optional and only used in tests at the moment
10100
10145
  struct DBConfig {
10101
10146
  friend class DatabaseInstance;
10102
10147
  friend class StorageManager;
@@ -10136,8 +10181,6 @@ public:
10136
10181
  bool enable_external_access = true;
10137
10182
  //! Whether or not object cache is used
10138
10183
  bool object_cache_enable = false;
10139
- //! Database configuration variables as controlled by SET
10140
- case_insensitive_map_t<Value> set_variables;
10141
10184
  //! Force checkpoint when CHECKPOINT is called or on shutdown, even if no changes have been made
10142
10185
  bool force_checkpoint = false;
10143
10186
  //! Run a checkpoint on successful shutdown and delete the WAL, to leave only a single database file behind
@@ -10158,6 +10201,14 @@ public:
10158
10201
  //! Debug setting for window aggregation mode: (window, combine, separate)
10159
10202
  WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
10160
10203
 
10204
+ //! Extra parameters that can be SET for loaded extensions
10205
+ case_insensitive_map_t<ExtensionOption> extension_parameters;
10206
+ //! Database configuration variables as controlled by SET
10207
+ case_insensitive_map_t<Value> set_variables;
10208
+
10209
+ DUCKDB_API void AddExtensionOption(string name, string description, LogicalType parameter,
10210
+ set_option_callback_t function = nullptr);
10211
+
10161
10212
  public:
10162
10213
  DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
10163
10214
  DUCKDB_API static DBConfig &GetConfig(DatabaseInstance &db);
@@ -10203,8 +10254,10 @@ class DuckDB;
10203
10254
  //! The Extension class is the base class used to define extensions
10204
10255
  class Extension {
10205
10256
  public:
10257
+ DUCKDB_API virtual ~Extension();
10258
+
10206
10259
  DUCKDB_API virtual void Load(DuckDB &db) = 0;
10207
- DUCKDB_API virtual ~Extension() = default;
10260
+ DUCKDB_API virtual std::string Name() = 0;
10208
10261
  };
10209
10262
 
10210
10263
  } // namespace duckdb
@@ -10252,6 +10305,7 @@ private:
10252
10305
  unique_ptr<TaskScheduler> scheduler;
10253
10306
  unique_ptr<ObjectCache> object_cache;
10254
10307
  unique_ptr<ConnectionManager> connection_manager;
10308
+ unordered_set<std::string> loaded_extensions;
10255
10309
  };
10256
10310
 
10257
10311
  //! The database object. This object holds the catalog and all the
@@ -10260,6 +10314,8 @@ class DuckDB {
10260
10314
  public:
10261
10315
  DUCKDB_API explicit DuckDB(const char *path = nullptr, DBConfig *config = nullptr);
10262
10316
  DUCKDB_API explicit DuckDB(const string &path, DBConfig *config = nullptr);
10317
+ DUCKDB_API explicit DuckDB(DatabaseInstance &instance);
10318
+
10263
10319
  DUCKDB_API ~DuckDB();
10264
10320
 
10265
10321
  //! Reference to the actual database instance
@@ -10269,7 +10325,11 @@ public:
10269
10325
  template <class T>
10270
10326
  void LoadExtension() {
10271
10327
  T extension;
10328
+ if (ExtensionIsLoaded(extension.Name())) {
10329
+ return;
10330
+ }
10272
10331
  extension.Load(*this);
10332
+ SetExtensionLoaded(extension.Name());
10273
10333
  }
10274
10334
 
10275
10335
  DUCKDB_API FileSystem &GetFileSystem();
@@ -10277,16 +10337,39 @@ public:
10277
10337
  DUCKDB_API idx_t NumberOfThreads();
10278
10338
  DUCKDB_API static const char *SourceID();
10279
10339
  DUCKDB_API static const char *LibraryVersion();
10340
+ DUCKDB_API static string Platform();
10341
+ DUCKDB_API bool ExtensionIsLoaded(const std::string &name);
10342
+ DUCKDB_API void SetExtensionLoaded(const std::string &name);
10280
10343
  };
10281
10344
 
10282
10345
  } // namespace duckdb
10283
10346
 
10284
10347
 
10348
+ //===----------------------------------------------------------------------===//
10349
+ // DuckDB
10350
+ //
10351
+ // duckdb/main/loadable_extension.hpp
10352
+ //
10353
+ //
10354
+ //===----------------------------------------------------------------------===//
10355
+
10285
10356
 
10286
10357
 
10287
10358
  #ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
10288
10359
  #ifdef _WIN32
10360
+ #ifndef NOMINMAX
10361
+ #define NOMINMAX
10362
+ #endif
10363
+
10364
+ #ifndef _WINSOCKAPI_
10365
+ #define _WINSOCKAPI_
10366
+ #endif
10289
10367
  #include <windows.h>
10368
+
10369
+ #undef CreateDirectory
10370
+ #undef MoveFile
10371
+ #undef RemoveDirectory
10372
+
10290
10373
  #include <delayimp.h>
10291
10374
 
10292
10375
  extern "C" {
@@ -10294,7 +10377,7 @@ extern "C" {
10294
10377
  This is interesting: Windows would normally require a duckdb.dll being on the DLL search path when we load an extension
10295
10378
  using LoadLibrary(). However, there is likely no such dll, because DuckDB was statically linked, or is running as part
10296
10379
  of an R or Python module with a completely different name (that we don't know) or something of the sorts. Amazingly,
10297
- Windows supports lazy-loading DLLs by linking them with /DELAYLOAD. Then a callback will be triggerd whenever we access
10380
+ Windows supports lazy-loading DLLs by linking them with /DELAYLOAD. Then a callback will be triggered whenever we access
10298
10381
  symbols in the extension. Since DuckDB is already running in the host process (hopefully), we can use
10299
10382
  GetModuleHandle(NULL) to return the current process so the symbols are looked for there. See here for another
10300
10383
  explanation of this crazy process:
@@ -10332,8 +10415,9 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
10332
10415
 
10333
10416
 
10334
10417
 
10418
+ #ifndef DUCKDB_API
10335
10419
  #ifdef _WIN32
10336
- #ifdef DUCKDB_BUILD_LIBRARY
10420
+ #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
10337
10421
  #define DUCKDB_API __declspec(dllexport)
10338
10422
  #else
10339
10423
  #define DUCKDB_API __declspec(dllimport)
@@ -10341,6 +10425,7 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
10341
10425
  #else
10342
10426
  #define DUCKDB_API
10343
10427
  #endif
10428
+ #endif
10344
10429
 
10345
10430
  #include <stdbool.h>
10346
10431
  #include <stdint.h>
@@ -11735,6 +11820,12 @@ struct timestamp_struct {
11735
11820
  //! The Timestamp class is a static class that holds helper functions for the Timestamp
11736
11821
  //! type.
11737
11822
  class Timestamp {
11823
+ public:
11824
+ // min timestamp is 290308-12-22 (BC)
11825
+ constexpr static const int32_t MIN_YEAR = -290308;
11826
+ constexpr static const int32_t MIN_MONTH = 12;
11827
+ constexpr static const int32_t MIN_DAY = 22;
11828
+
11738
11829
  public:
11739
11830
  //! Convert a string in the format "YYYY-MM-DD hh:mm:ss" to a timestamp object
11740
11831
  DUCKDB_API static timestamp_t FromString(const string &str);
@@ -11807,6 +11898,8 @@ public:
11807
11898
 
11808
11899
  //! Convert a time object to a string in the format "hh:mm:ss"
11809
11900
  DUCKDB_API static string ToString(dtime_t time);
11901
+ //! Convert a UTC offset to ±HH[:MM]
11902
+ DUCKDB_API static string ToUTCOffset(int hour_offset, int minute_offset);
11810
11903
 
11811
11904
  DUCKDB_API static dtime_t FromTime(int32_t hour, int32_t minute, int32_t second, int32_t microseconds = 0);
11812
11905
 
@@ -11894,14 +11987,11 @@ class TableCatalogEntry;
11894
11987
  class Connection;
11895
11988
 
11896
11989
  //! The Appender class can be used to append elements to a table.
11897
- class Appender {
11990
+ class BaseAppender {
11991
+ protected:
11898
11992
  //! The amount of chunks that will be gathered in the chunk collection before flushing
11899
11993
  static constexpr const idx_t FLUSH_COUNT = 100;
11900
11994
 
11901
- //! A reference to a database connection that created this appender
11902
- shared_ptr<ClientContext> context;
11903
- //! The table description (including column names)
11904
- unique_ptr<TableDescription> description;
11905
11995
  //! The append types
11906
11996
  vector<LogicalType> types;
11907
11997
  //! The buffered data for the append
@@ -11912,9 +12002,9 @@ class Appender {
11912
12002
  idx_t column = 0;
11913
12003
 
11914
12004
  public:
11915
- DUCKDB_API Appender(Connection &con, const string &schema_name, const string &table_name);
11916
- DUCKDB_API Appender(Connection &con, const string &table_name);
11917
- DUCKDB_API ~Appender();
12005
+ DUCKDB_API BaseAppender();
12006
+ DUCKDB_API BaseAppender(vector<LogicalType> types);
12007
+ DUCKDB_API virtual ~BaseAppender();
11918
12008
 
11919
12009
  //! Begins a new row append, after calling this the other AppendX() functions
11920
12010
  //! should be called the correct amount of times. After that,
@@ -11950,7 +12040,9 @@ public:
11950
12040
  return column;
11951
12041
  }
11952
12042
 
11953
- private:
12043
+ protected:
12044
+ void Destructor();
12045
+ virtual void FlushInternal(ChunkCollection &collection) = 0;
11954
12046
  void InitializeChunk();
11955
12047
  void FlushChunk();
11956
12048
 
@@ -11972,46 +12064,75 @@ private:
11972
12064
  void AppendValue(const Value &value);
11973
12065
  };
11974
12066
 
12067
+ class Appender : public BaseAppender {
12068
+ //! A reference to a database connection that created this appender
12069
+ shared_ptr<ClientContext> context;
12070
+ //! The table description (including column names)
12071
+ unique_ptr<TableDescription> description;
12072
+
12073
+ public:
12074
+ DUCKDB_API Appender(Connection &con, const string &schema_name, const string &table_name);
12075
+ DUCKDB_API Appender(Connection &con, const string &table_name);
12076
+ DUCKDB_API ~Appender() override;
12077
+
12078
+ protected:
12079
+ void FlushInternal(ChunkCollection &collection) override;
12080
+ };
12081
+
12082
+ class InternalAppender : public BaseAppender {
12083
+ //! The client context
12084
+ ClientContext &context;
12085
+ //! The internal table entry to append to
12086
+ TableCatalogEntry &table;
12087
+
12088
+ public:
12089
+ DUCKDB_API InternalAppender(ClientContext &context, TableCatalogEntry &table);
12090
+ DUCKDB_API ~InternalAppender() override;
12091
+
12092
+ protected:
12093
+ void FlushInternal(ChunkCollection &collection) override;
12094
+ };
12095
+
11975
12096
  template <>
11976
- void DUCKDB_API Appender::Append(bool value);
12097
+ DUCKDB_API void BaseAppender::Append(bool value);
11977
12098
  template <>
11978
- void DUCKDB_API Appender::Append(int8_t value);
12099
+ DUCKDB_API void BaseAppender::Append(int8_t value);
11979
12100
  template <>
11980
- void DUCKDB_API Appender::Append(int16_t value);
12101
+ DUCKDB_API void BaseAppender::Append(int16_t value);
11981
12102
  template <>
11982
- void DUCKDB_API Appender::Append(int32_t value);
12103
+ DUCKDB_API void BaseAppender::Append(int32_t value);
11983
12104
  template <>
11984
- void DUCKDB_API Appender::Append(int64_t value);
12105
+ DUCKDB_API void BaseAppender::Append(int64_t value);
11985
12106
  template <>
11986
- void DUCKDB_API Appender::Append(hugeint_t value);
12107
+ DUCKDB_API void BaseAppender::Append(hugeint_t value);
11987
12108
  template <>
11988
- void DUCKDB_API Appender::Append(uint8_t value);
12109
+ DUCKDB_API void BaseAppender::Append(uint8_t value);
11989
12110
  template <>
11990
- void DUCKDB_API Appender::Append(uint16_t value);
12111
+ DUCKDB_API void BaseAppender::Append(uint16_t value);
11991
12112
  template <>
11992
- void DUCKDB_API Appender::Append(uint32_t value);
12113
+ DUCKDB_API void BaseAppender::Append(uint32_t value);
11993
12114
  template <>
11994
- void DUCKDB_API Appender::Append(uint64_t value);
12115
+ DUCKDB_API void BaseAppender::Append(uint64_t value);
11995
12116
  template <>
11996
- void DUCKDB_API Appender::Append(float value);
12117
+ DUCKDB_API void BaseAppender::Append(float value);
11997
12118
  template <>
11998
- void DUCKDB_API Appender::Append(double value);
12119
+ DUCKDB_API void BaseAppender::Append(double value);
11999
12120
  template <>
12000
- void DUCKDB_API Appender::Append(date_t value);
12121
+ DUCKDB_API void BaseAppender::Append(date_t value);
12001
12122
  template <>
12002
- void DUCKDB_API Appender::Append(dtime_t value);
12123
+ DUCKDB_API void BaseAppender::Append(dtime_t value);
12003
12124
  template <>
12004
- void DUCKDB_API Appender::Append(timestamp_t value);
12125
+ DUCKDB_API void BaseAppender::Append(timestamp_t value);
12005
12126
  template <>
12006
- void DUCKDB_API Appender::Append(interval_t value);
12127
+ DUCKDB_API void BaseAppender::Append(interval_t value);
12007
12128
  template <>
12008
- void DUCKDB_API Appender::Append(const char *value);
12129
+ DUCKDB_API void BaseAppender::Append(const char *value);
12009
12130
  template <>
12010
- void DUCKDB_API Appender::Append(string_t value);
12131
+ DUCKDB_API void BaseAppender::Append(string_t value);
12011
12132
  template <>
12012
- void DUCKDB_API Appender::Append(Value value);
12133
+ DUCKDB_API void BaseAppender::Append(Value value);
12013
12134
  template <>
12014
- void DUCKDB_API Appender::Append(std::nullptr_t value);
12135
+ DUCKDB_API void BaseAppender::Append(std::nullptr_t value);
12015
12136
 
12016
12137
  } // namespace duckdb
12017
12138
  //===----------------------------------------------------------------------===//
@@ -12175,22 +12296,21 @@ enum class ConstraintType : uint8_t {
12175
12296
  //! Constraint is the base class of any type of table constraint.
12176
12297
  class Constraint {
12177
12298
  public:
12178
- explicit Constraint(ConstraintType type) : type(type) {};
12179
- virtual ~Constraint() {
12180
- }
12299
+ DUCKDB_API explicit Constraint(ConstraintType type);
12300
+ DUCKDB_API virtual ~Constraint();
12181
12301
 
12182
12302
  ConstraintType type;
12183
12303
 
12184
12304
  public:
12185
- virtual string ToString() const = 0;
12186
- void Print();
12305
+ DUCKDB_API virtual string ToString() const = 0;
12306
+ DUCKDB_API void Print();
12187
12307
 
12188
- virtual unique_ptr<Constraint> Copy() = 0;
12308
+ DUCKDB_API virtual unique_ptr<Constraint> Copy() = 0;
12189
12309
  //! Serializes a Constraint to a stand-alone binary blob
12190
- virtual void Serialize(Serializer &serializer);
12310
+ DUCKDB_API virtual void Serialize(Serializer &serializer);
12191
12311
  //! Deserializes a blob back into a Constraint, returns NULL if
12192
12312
  //! deserialization is not possible
12193
- static unique_ptr<Constraint> Deserialize(Deserializer &source);
12313
+ DUCKDB_API static unique_ptr<Constraint> Deserialize(Deserializer &source);
12194
12314
  };
12195
12315
  } // namespace duckdb
12196
12316
 
@@ -12278,7 +12398,7 @@ public:
12278
12398
 
12279
12399
  //! Returns the column index of the specified column name.
12280
12400
  //! If the column does not exist:
12281
- //! If if_exists is true, returns INVALID_INDEX
12401
+ //! If if_exists is true, returns DConstants::INVALID_INDEX
12282
12402
  //! If if_exists is false, throws an exception
12283
12403
  idx_t GetColumnIndex(string &name, bool if_exists = false);
12284
12404
 
@@ -12317,21 +12437,21 @@ class CatalogSet {
12317
12437
  friend class DependencyManager;
12318
12438
 
12319
12439
  public:
12320
- explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
12440
+ DUCKDB_API explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
12321
12441
 
12322
12442
  //! Create an entry in the catalog set. Returns whether or not it was
12323
12443
  //! successful.
12324
- bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
12325
- unordered_set<CatalogEntry *> &dependencies);
12444
+ DUCKDB_API bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
12445
+ unordered_set<CatalogEntry *> &dependencies);
12326
12446
 
12327
- bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
12447
+ DUCKDB_API bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
12328
12448
 
12329
- bool DropEntry(ClientContext &context, const string &name, bool cascade);
12449
+ DUCKDB_API bool DropEntry(ClientContext &context, const string &name, bool cascade);
12330
12450
 
12331
12451
  void CleanupEntry(CatalogEntry *catalog_entry);
12332
12452
 
12333
12453
  //! Returns the entry with the specified name
12334
- CatalogEntry *GetEntry(ClientContext &context, const string &name);
12454
+ DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &name);
12335
12455
 
12336
12456
  //! Gets the entry that is most similar to the given name (i.e. smallest levenshtein distance), or empty string if
12337
12457
  //! none is found. The returned pair consists of the entry name and the distance (smaller means closer).
@@ -12342,9 +12462,9 @@ public:
12342
12462
  void Undo(CatalogEntry *entry);
12343
12463
 
12344
12464
  //! Scan the catalog set, invoking the callback method for every committed entry
12345
- void Scan(const std::function<void(CatalogEntry *)> &callback);
12465
+ DUCKDB_API void Scan(const std::function<void(CatalogEntry *)> &callback);
12346
12466
  //! Scan the catalog set, invoking the callback method for every entry
12347
- void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
12467
+ DUCKDB_API void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
12348
12468
 
12349
12469
  template <class T>
12350
12470
  vector<T *> GetEntries(ClientContext &context) {
@@ -12353,8 +12473,8 @@ public:
12353
12473
  return result;
12354
12474
  }
12355
12475
 
12356
- static bool HasConflict(ClientContext &context, transaction_t timestamp);
12357
- static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
12476
+ DUCKDB_API static bool HasConflict(ClientContext &context, transaction_t timestamp);
12477
+ DUCKDB_API static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
12358
12478
 
12359
12479
  CatalogEntry *GetEntryFromIndex(idx_t index);
12360
12480
  void UpdateTimestamp(CatalogEntry *entry, transaction_t timestamp);
@@ -12490,6 +12610,9 @@ private:
12490
12610
  //! Drops an entry from the schema
12491
12611
  void DropEntry(ClientContext &context, DropInfo *info);
12492
12612
 
12613
+ //! Append a scalar or aggregate function within the given schema
12614
+ CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
12615
+
12493
12616
  //! Alters a catalog entry
12494
12617
  void Alter(ClientContext &context, AlterInfo *info);
12495
12618
 
@@ -12505,7 +12628,6 @@ private:
12505
12628
  } // namespace duckdb
12506
12629
 
12507
12630
 
12508
-
12509
12631
  //===----------------------------------------------------------------------===//
12510
12632
  // DuckDB
12511
12633
  //
@@ -12521,24 +12643,6 @@ private:
12521
12643
  namespace duckdb {
12522
12644
  using std::deque;
12523
12645
  }
12524
- //===----------------------------------------------------------------------===//
12525
- // DuckDB
12526
- //
12527
- // duckdb/common/enums/output_type.hpp
12528
- //
12529
- //
12530
- //===----------------------------------------------------------------------===//
12531
-
12532
-
12533
-
12534
-
12535
-
12536
- namespace duckdb {
12537
-
12538
- enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
12539
-
12540
- } // namespace duckdb
12541
-
12542
12646
 
12543
12647
  //===----------------------------------------------------------------------===//
12544
12648
  // DuckDB
@@ -12627,6 +12731,7 @@ enum class PhysicalOperatorType : uint8_t {
12627
12731
  INVALID,
12628
12732
  ORDER_BY,
12629
12733
  LIMIT,
12734
+ LIMIT_PERCENT,
12630
12735
  TOP_N,
12631
12736
  WINDOW,
12632
12737
  UNNEST,
@@ -12690,6 +12795,7 @@ enum class PhysicalOperatorType : uint8_t {
12690
12795
  // Helpers
12691
12796
  // -----------------------------
12692
12797
  EXPLAIN,
12798
+ EXPLAIN_ANALYZE,
12693
12799
  EMPTY_RESULT,
12694
12800
  EXECUTE,
12695
12801
  PREPARE,
@@ -12838,7 +12944,7 @@ public:
12838
12944
  vector<unique_ptr<PhysicalOperator>> children;
12839
12945
  //! The types returned by this physical operator
12840
12946
  vector<LogicalType> types;
12841
- //! The extimated cardinality of this physical operator
12947
+ //! The estimated cardinality of this physical operator
12842
12948
  idx_t estimated_cardinality;
12843
12949
  //! The global sink state of this operator
12844
12950
  unique_ptr<GlobalSinkState> sink_state;
@@ -12948,14 +13054,13 @@ struct ParallelState;
12948
13054
  class TableFilterSet;
12949
13055
 
12950
13056
  struct FunctionOperatorData {
12951
- virtual ~FunctionOperatorData() {
12952
- }
13057
+ DUCKDB_API virtual ~FunctionOperatorData();
12953
13058
  };
12954
13059
 
12955
13060
  struct TableFilterCollection {
13061
+ DUCKDB_API explicit TableFilterCollection(TableFilterSet *table_filters);
13062
+
12956
13063
  TableFilterSet *table_filters;
12957
- explicit TableFilterCollection(TableFilterSet *table_filters) : table_filters(table_filters) {
12958
- }
12959
13064
  };
12960
13065
 
12961
13066
  typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, vector<Value> &inputs,
@@ -13000,6 +13105,7 @@ typedef string (*table_function_to_string_t)(const FunctionData *bind_data);
13000
13105
 
13001
13106
  class TableFunction : public SimpleNamedParameterFunction {
13002
13107
  public:
13108
+ DUCKDB_API
13003
13109
  TableFunction(string name, vector<LogicalType> arguments, table_function_t function,
13004
13110
  table_function_bind_t bind = nullptr, table_function_init_t init = nullptr,
13005
13111
  table_statistics_t statistics = nullptr, table_function_cleanup_t cleanup = nullptr,
@@ -13010,14 +13116,8 @@ public:
13010
13116
  table_function_parallel_t parallel_function = nullptr,
13011
13117
  table_function_init_parallel_t parallel_init = nullptr,
13012
13118
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
13013
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr)
13014
- : SimpleNamedParameterFunction(std::move(name), move(arguments)), bind(bind), init(init), function(function),
13015
- statistics(statistics), cleanup(cleanup), dependency(dependency), cardinality(cardinality),
13016
- pushdown_complex_filter(pushdown_complex_filter), to_string(to_string), max_threads(max_threads),
13017
- init_parallel_state(init_parallel_state), parallel_function(parallel_function), parallel_init(parallel_init),
13018
- parallel_state_next(parallel_state_next), table_scan_progress(query_progress),
13019
- projection_pushdown(projection_pushdown), filter_pushdown(filter_pushdown) {
13020
- }
13119
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
13120
+ DUCKDB_API
13021
13121
  TableFunction(const vector<LogicalType> &arguments, table_function_t function, table_function_bind_t bind = nullptr,
13022
13122
  table_function_init_t init = nullptr, table_statistics_t statistics = nullptr,
13023
13123
  table_function_cleanup_t cleanup = nullptr, table_function_dependency_t dependency = nullptr,
@@ -13028,13 +13128,8 @@ public:
13028
13128
  table_function_parallel_t parallel_function = nullptr,
13029
13129
  table_function_init_parallel_t parallel_init = nullptr,
13030
13130
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
13031
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr)
13032
- : TableFunction(string(), arguments, function, bind, init, statistics, cleanup, dependency, cardinality,
13033
- pushdown_complex_filter, to_string, max_threads, init_parallel_state, parallel_function,
13034
- parallel_init, parallel_state_next, projection_pushdown, filter_pushdown, query_progress) {
13035
- }
13036
- TableFunction() : SimpleNamedParameterFunction("", {}) {
13037
- }
13131
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
13132
+ DUCKDB_API TableFunction();
13038
13133
 
13039
13134
  //! Bind function
13040
13135
  //! This function is used for determining the return type of a table producing function and returning bind data
@@ -13082,10 +13177,6 @@ public:
13082
13177
  //! Whether or not the table function supports filter pushdown. If not supported a filter will be added
13083
13178
  //! that applies the table filter directly.
13084
13179
  bool filter_pushdown;
13085
-
13086
- string ToString() override {
13087
- return SimpleNamedParameterFunction::ToString();
13088
- }
13089
13180
  };
13090
13181
 
13091
13182
  } // namespace duckdb
@@ -13170,6 +13261,7 @@ namespace duckdb {
13170
13261
  struct ConcurrentQueue;
13171
13262
  struct QueueProducerToken;
13172
13263
  class ClientContext;
13264
+ class DatabaseInstance;
13173
13265
  class TaskScheduler;
13174
13266
 
13175
13267
  struct SchedulerThread;
@@ -13193,6 +13285,7 @@ public:
13193
13285
  ~TaskScheduler();
13194
13286
 
13195
13287
  static TaskScheduler &GetScheduler(ClientContext &context);
13288
+ static TaskScheduler &GetScheduler(DatabaseInstance &db);
13196
13289
 
13197
13290
  unique_ptr<ProducerToken> CreateProducer();
13198
13291
  //! Schedule a task to be executed by the task scheduler
@@ -13437,7 +13530,7 @@ public:
13437
13530
  //! Starts the thread
13438
13531
  void Start();
13439
13532
  //! Stops the thread
13440
- void Stop();
13533
+ void Stop(bool success = true);
13441
13534
  //! Gets current percentage
13442
13535
  int GetCurrentPercentage();
13443
13536
 
@@ -13454,7 +13547,7 @@ private:
13454
13547
  std::condition_variable c;
13455
13548
  mutex m;
13456
13549
  #endif
13457
- idx_t show_progress_after;
13550
+ atomic<idx_t> show_progress_after;
13458
13551
  idx_t time_update_bar;
13459
13552
  atomic<int> current_percentage;
13460
13553
  atomic<bool> stop;
@@ -13540,6 +13633,75 @@ private:
13540
13633
 
13541
13634
  #include <random>
13542
13635
 
13636
+ //===----------------------------------------------------------------------===//
13637
+ // DuckDB
13638
+ //
13639
+ // duckdb/main/client_config.hpp
13640
+ //
13641
+ //
13642
+ //===----------------------------------------------------------------------===//
13643
+
13644
+
13645
+
13646
+
13647
+
13648
+ //===----------------------------------------------------------------------===//
13649
+ // DuckDB
13650
+ //
13651
+ // duckdb/common/enums/output_type.hpp
13652
+ //
13653
+ //
13654
+ //===----------------------------------------------------------------------===//
13655
+
13656
+
13657
+
13658
+
13659
+
13660
+ namespace duckdb {
13661
+
13662
+ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
13663
+
13664
+ } // namespace duckdb
13665
+
13666
+
13667
+
13668
+ namespace duckdb {
13669
+ class ClientContext;
13670
+
13671
+ struct ClientConfig {
13672
+ //! If the progress bar is enabled or not.
13673
+ bool enable_progress_bar = false;
13674
+ //! If the print of the progress bar is enabled
13675
+ bool print_progress_bar = true;
13676
+ //! The wait time before showing the progress bar
13677
+ int wait_time = 2000;
13678
+
13679
+ // Whether or not aggressive query verification is enabled
13680
+ bool query_verification_enabled = false;
13681
+ //! Enable the running of optimizers
13682
+ bool enable_optimizer = true;
13683
+ //! Force parallelism of small tables, used for testing
13684
+ bool verify_parallelism = false;
13685
+ //! Force index join independent of table cardinality, used for testing
13686
+ bool force_index_join = false;
13687
+ //! Force out-of-core computation for operators that support it, used for testing
13688
+ bool force_external = false;
13689
+ //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13690
+ //! elements)
13691
+ idx_t perfect_ht_threshold = 12;
13692
+
13693
+ //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13694
+ ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13695
+
13696
+ //! Generic options
13697
+ case_insensitive_map_t<Value> set_variables;
13698
+
13699
+ public:
13700
+ static ClientConfig &GetConfig(ClientContext &context);
13701
+ };
13702
+
13703
+ } // namespace duckdb
13704
+
13543
13705
 
13544
13706
  namespace duckdb {
13545
13707
  class Appender;
@@ -13584,35 +13746,12 @@ public:
13584
13746
 
13585
13747
  //! The Progress Bar
13586
13748
  unique_ptr<ProgressBar> progress_bar;
13587
- //! If the progress bar is enabled or not.
13588
- bool enable_progress_bar = false;
13589
- //! If the print of the progress bar is enabled
13590
- bool print_progress_bar = true;
13591
- //! The wait time before showing the progress bar
13592
- int wait_time = 2000;
13593
13749
 
13594
13750
  unique_ptr<SchemaCatalogEntry> temporary_objects;
13595
13751
  unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
13596
13752
 
13597
- case_insensitive_map_t<Value> set_variables;
13598
-
13599
- // Whether or not aggressive query verification is enabled
13600
- bool query_verification_enabled = false;
13601
- //! Enable the running of optimizers
13602
- bool enable_optimizer = true;
13603
- //! Force parallelism of small tables, used for testing
13604
- bool verify_parallelism = false;
13605
- //! Force index join independent of table cardinality, used for testing
13606
- bool force_index_join = false;
13607
- //! Force out-of-core computation for operators that support it, used for testing
13608
- bool force_external = false;
13609
- //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13610
- //! elements)
13611
- idx_t perfect_ht_threshold = 12;
13612
13753
  //! The writer used to log queries (if logging is enabled)
13613
13754
  unique_ptr<BufferedFileWriter> log_query_writer;
13614
- //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13615
- ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13616
13755
  //! The random generator used by random(). Its seed value can be set by setseed().
13617
13756
  std::mt19937 random_engine;
13618
13757
 
@@ -13620,6 +13759,9 @@ public:
13620
13759
 
13621
13760
  unique_ptr<FileOpener> file_opener;
13622
13761
 
13762
+ //! The client configuration
13763
+ ClientConfig config;
13764
+
13623
13765
  public:
13624
13766
  DUCKDB_API Transaction &ActiveTransaction() {
13625
13767
  return transaction.ActiveTransaction();