duckdb 0.3.2-dev50.0 → 0.3.2-dev524.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 +45062 -29658
  3. package/src/duckdb.hpp +776 -630
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 "1f398ce3b"
14
- #define DUCKDB_VERSION "0.3.2-dev50"
13
+ #define DUCKDB_SOURCE_ID "469e6a48f"
14
+ #define DUCKDB_VERSION "0.3.2-dev524"
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
 
@@ -1261,20 +1270,21 @@ enum class ExceptionType {
1261
1270
  INTERNAL =
1262
1271
  31, // Internal exception: exception that indicates something went wrong internally (i.e. bug in the code base)
1263
1272
  INVALID_INPUT = 32, // Input or arguments error
1264
- OUT_OF_MEMORY = 33 // out of memory
1273
+ OUT_OF_MEMORY = 33, // out of memory
1274
+ PERMISSION = 34 // insufficient permissions
1265
1275
  };
1266
1276
 
1267
1277
  class Exception : public std::exception {
1268
1278
  public:
1269
- explicit Exception(const string &msg);
1270
- Exception(ExceptionType exception_type, const string &message);
1279
+ DUCKDB_API explicit Exception(const string &msg);
1280
+ DUCKDB_API Exception(ExceptionType exception_type, const string &message);
1271
1281
 
1272
1282
  ExceptionType type;
1273
1283
 
1274
1284
  public:
1275
- const char *what() const noexcept override;
1285
+ DUCKDB_API const char *what() const noexcept override;
1276
1286
 
1277
- string ExceptionTypeToString(ExceptionType type);
1287
+ DUCKDB_API string ExceptionTypeToString(ExceptionType type);
1278
1288
 
1279
1289
  template <typename... Args>
1280
1290
  static string ConstructMessage(const string &msg, Args... params) {
@@ -1282,7 +1292,7 @@ public:
1282
1292
  return ConstructMessageRecursive(msg, values, params...);
1283
1293
  }
1284
1294
 
1285
- static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values);
1295
+ DUCKDB_API static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values);
1286
1296
 
1287
1297
  template <class T, typename... Args>
1288
1298
  static string ConstructMessageRecursive(const string &msg, vector<ExceptionFormatValue> &values, T param,
@@ -1291,6 +1301,8 @@ public:
1291
1301
  return ConstructMessageRecursive(msg, values, params...);
1292
1302
  }
1293
1303
 
1304
+ DUCKDB_API static bool UncaughtException();
1305
+
1294
1306
  private:
1295
1307
  string exception_message_;
1296
1308
  };
@@ -1302,13 +1314,12 @@ private:
1302
1314
  //! Exceptions that are StandardExceptions do NOT invalidate the current transaction when thrown
1303
1315
  class StandardException : public Exception {
1304
1316
  public:
1305
- StandardException(ExceptionType exception_type, string message) : Exception(exception_type, message) {
1306
- }
1317
+ DUCKDB_API StandardException(ExceptionType exception_type, const string &message);
1307
1318
  };
1308
1319
 
1309
1320
  class CatalogException : public StandardException {
1310
1321
  public:
1311
- explicit CatalogException(const string &msg);
1322
+ DUCKDB_API explicit CatalogException(const string &msg);
1312
1323
 
1313
1324
  template <typename... Args>
1314
1325
  explicit CatalogException(const string &msg, Args... params) : CatalogException(ConstructMessage(msg, params...)) {
@@ -1317,16 +1328,26 @@ public:
1317
1328
 
1318
1329
  class ParserException : public StandardException {
1319
1330
  public:
1320
- explicit ParserException(const string &msg);
1331
+ DUCKDB_API explicit ParserException(const string &msg);
1321
1332
 
1322
1333
  template <typename... Args>
1323
1334
  explicit ParserException(const string &msg, Args... params) : ParserException(ConstructMessage(msg, params...)) {
1324
1335
  }
1325
1336
  };
1326
1337
 
1338
+ class PermissionException : public StandardException {
1339
+ public:
1340
+ DUCKDB_API explicit PermissionException(const string &msg);
1341
+
1342
+ template <typename... Args>
1343
+ explicit PermissionException(const string &msg, Args... params)
1344
+ : PermissionException(ConstructMessage(msg, params...)) {
1345
+ }
1346
+ };
1347
+
1327
1348
  class BinderException : public StandardException {
1328
1349
  public:
1329
- explicit BinderException(const string &msg);
1350
+ DUCKDB_API explicit BinderException(const string &msg);
1330
1351
 
1331
1352
  template <typename... Args>
1332
1353
  explicit BinderException(const string &msg, Args... params) : BinderException(ConstructMessage(msg, params...)) {
@@ -1335,7 +1356,7 @@ public:
1335
1356
 
1336
1357
  class ConversionException : public Exception {
1337
1358
  public:
1338
- explicit ConversionException(const string &msg);
1359
+ DUCKDB_API explicit ConversionException(const string &msg);
1339
1360
 
1340
1361
  template <typename... Args>
1341
1362
  explicit ConversionException(const string &msg, Args... params)
@@ -1345,7 +1366,7 @@ public:
1345
1366
 
1346
1367
  class TransactionException : public Exception {
1347
1368
  public:
1348
- explicit TransactionException(const string &msg);
1369
+ DUCKDB_API explicit TransactionException(const string &msg);
1349
1370
 
1350
1371
  template <typename... Args>
1351
1372
  explicit TransactionException(const string &msg, Args... params)
@@ -1355,7 +1376,7 @@ public:
1355
1376
 
1356
1377
  class NotImplementedException : public Exception {
1357
1378
  public:
1358
- explicit NotImplementedException(const string &msg);
1379
+ DUCKDB_API explicit NotImplementedException(const string &msg);
1359
1380
 
1360
1381
  template <typename... Args>
1361
1382
  explicit NotImplementedException(const string &msg, Args... params)
@@ -1365,7 +1386,7 @@ public:
1365
1386
 
1366
1387
  class OutOfRangeException : public Exception {
1367
1388
  public:
1368
- explicit OutOfRangeException(const string &msg);
1389
+ DUCKDB_API explicit OutOfRangeException(const string &msg);
1369
1390
 
1370
1391
  template <typename... Args>
1371
1392
  explicit OutOfRangeException(const string &msg, Args... params)
@@ -1375,7 +1396,7 @@ public:
1375
1396
 
1376
1397
  class OutOfMemoryException : public Exception {
1377
1398
  public:
1378
- explicit OutOfMemoryException(const string &msg);
1399
+ DUCKDB_API explicit OutOfMemoryException(const string &msg);
1379
1400
 
1380
1401
  template <typename... Args>
1381
1402
  explicit OutOfMemoryException(const string &msg, Args... params)
@@ -1385,7 +1406,7 @@ public:
1385
1406
 
1386
1407
  class SyntaxException : public Exception {
1387
1408
  public:
1388
- explicit SyntaxException(const string &msg);
1409
+ DUCKDB_API explicit SyntaxException(const string &msg);
1389
1410
 
1390
1411
  template <typename... Args>
1391
1412
  explicit SyntaxException(const string &msg, Args... params) : SyntaxException(ConstructMessage(msg, params...)) {
@@ -1394,7 +1415,7 @@ public:
1394
1415
 
1395
1416
  class ConstraintException : public Exception {
1396
1417
  public:
1397
- explicit ConstraintException(const string &msg);
1418
+ DUCKDB_API explicit ConstraintException(const string &msg);
1398
1419
 
1399
1420
  template <typename... Args>
1400
1421
  explicit ConstraintException(const string &msg, Args... params)
@@ -1404,7 +1425,7 @@ public:
1404
1425
 
1405
1426
  class IOException : public Exception {
1406
1427
  public:
1407
- explicit IOException(const string &msg);
1428
+ DUCKDB_API explicit IOException(const string &msg);
1408
1429
 
1409
1430
  template <typename... Args>
1410
1431
  explicit IOException(const string &msg, Args... params) : IOException(ConstructMessage(msg, params...)) {
@@ -1413,7 +1434,7 @@ public:
1413
1434
 
1414
1435
  class SerializationException : public Exception {
1415
1436
  public:
1416
- explicit SerializationException(const string &msg);
1437
+ DUCKDB_API explicit SerializationException(const string &msg);
1417
1438
 
1418
1439
  template <typename... Args>
1419
1440
  explicit SerializationException(const string &msg, Args... params)
@@ -1423,7 +1444,7 @@ public:
1423
1444
 
1424
1445
  class SequenceException : public Exception {
1425
1446
  public:
1426
- explicit SequenceException(const string &msg);
1447
+ DUCKDB_API explicit SequenceException(const string &msg);
1427
1448
 
1428
1449
  template <typename... Args>
1429
1450
  explicit SequenceException(const string &msg, Args... params)
@@ -1433,12 +1454,12 @@ public:
1433
1454
 
1434
1455
  class InterruptException : public Exception {
1435
1456
  public:
1436
- InterruptException();
1457
+ DUCKDB_API InterruptException();
1437
1458
  };
1438
1459
 
1439
1460
  class FatalException : public Exception {
1440
1461
  public:
1441
- explicit FatalException(const string &msg);
1462
+ DUCKDB_API explicit FatalException(const string &msg);
1442
1463
 
1443
1464
  template <typename... Args>
1444
1465
  explicit FatalException(const string &msg, Args... params) : FatalException(ConstructMessage(msg, params...)) {
@@ -1447,7 +1468,7 @@ public:
1447
1468
 
1448
1469
  class InternalException : public Exception {
1449
1470
  public:
1450
- explicit InternalException(const string &msg);
1471
+ DUCKDB_API explicit InternalException(const string &msg);
1451
1472
 
1452
1473
  template <typename... Args>
1453
1474
  explicit InternalException(const string &msg, Args... params)
@@ -1457,7 +1478,7 @@ public:
1457
1478
 
1458
1479
  class InvalidInputException : public Exception {
1459
1480
  public:
1460
- explicit InvalidInputException(const string &msg);
1481
+ DUCKDB_API explicit InvalidInputException(const string &msg);
1461
1482
 
1462
1483
  template <typename... Args>
1463
1484
  explicit InvalidInputException(const string &msg, Args... params)
@@ -1467,28 +1488,28 @@ public:
1467
1488
 
1468
1489
  class CastException : public Exception {
1469
1490
  public:
1470
- CastException(const PhysicalType origType, const PhysicalType newType);
1471
- CastException(const LogicalType &origType, const LogicalType &newType);
1491
+ DUCKDB_API CastException(const PhysicalType origType, const PhysicalType newType);
1492
+ DUCKDB_API CastException(const LogicalType &origType, const LogicalType &newType);
1472
1493
  };
1473
1494
 
1474
1495
  class InvalidTypeException : public Exception {
1475
1496
  public:
1476
- InvalidTypeException(PhysicalType type, const string &msg);
1477
- InvalidTypeException(const LogicalType &type, const string &msg);
1497
+ DUCKDB_API InvalidTypeException(PhysicalType type, const string &msg);
1498
+ DUCKDB_API InvalidTypeException(const LogicalType &type, const string &msg);
1478
1499
  };
1479
1500
 
1480
1501
  class TypeMismatchException : public Exception {
1481
1502
  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);
1503
+ DUCKDB_API TypeMismatchException(const PhysicalType type_1, const PhysicalType type_2, const string &msg);
1504
+ DUCKDB_API TypeMismatchException(const LogicalType &type_1, const LogicalType &type_2, const string &msg);
1484
1505
  };
1485
1506
 
1486
1507
  class ValueOutOfRangeException : public Exception {
1487
1508
  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);
1509
+ DUCKDB_API ValueOutOfRangeException(const int64_t value, const PhysicalType origType, const PhysicalType newType);
1510
+ DUCKDB_API ValueOutOfRangeException(const hugeint_t value, const PhysicalType origType, const PhysicalType newType);
1511
+ DUCKDB_API ValueOutOfRangeException(const double value, const PhysicalType origType, const PhysicalType newType);
1512
+ DUCKDB_API ValueOutOfRangeException(const PhysicalType varType, const idx_t length);
1492
1513
  };
1493
1514
 
1494
1515
  } // namespace duckdb
@@ -1718,7 +1739,9 @@ using std::unordered_map;
1718
1739
 
1719
1740
  namespace duckdb {
1720
1741
 
1721
- enum class FileCompressionType : uint8_t { AUTO_DETECT = 0, UNCOMPRESSED = 1, GZIP = 2 };
1742
+ enum class FileCompressionType : uint8_t { AUTO_DETECT = 0, UNCOMPRESSED = 1, GZIP = 2, ZSTD = 3 };
1743
+
1744
+ FileCompressionType FileCompressionTypeFromString(const string &input);
1722
1745
 
1723
1746
  } // namespace duckdb
1724
1747
 
@@ -1778,7 +1801,7 @@ public:
1778
1801
  idx_t GetFileSize();
1779
1802
  FileType GetType();
1780
1803
 
1781
- protected:
1804
+ //! Closes the file handle.
1782
1805
  virtual void Close() = 0;
1783
1806
 
1784
1807
  public:
@@ -1882,6 +1905,7 @@ public:
1882
1905
 
1883
1906
  //! registers a sub-file system to handle certain file name prefixes, e.g. http:// etc.
1884
1907
  virtual void RegisterSubSystem(unique_ptr<FileSystem> sub_fs);
1908
+ virtual void RegisterSubSystem(FileCompressionType compression_type, unique_ptr<FileSystem> fs);
1885
1909
 
1886
1910
  //! Whether or not a sub-system can handle a specific file path
1887
1911
  virtual bool CanHandleFile(const string &fpath);
@@ -1898,6 +1922,8 @@ public:
1898
1922
  //! in a file on-disk are much cheaper than e.g. random reads in a file over the network
1899
1923
  virtual bool OnDiskFile(FileHandle &handle);
1900
1924
 
1925
+ virtual unique_ptr<FileHandle> OpenCompressedFile(unique_ptr<FileHandle> handle, bool write);
1926
+
1901
1927
  //! Create a LocalFileSystem.
1902
1928
  static unique_ptr<FileSystem> CreateLocal();
1903
1929
 
@@ -1923,6 +1949,7 @@ public:
1923
1949
  FileOpener *opener = nullptr);
1924
1950
 
1925
1951
  FileSystem &fs;
1952
+ string path;
1926
1953
  unique_ptr<data_t[]> data;
1927
1954
  idx_t offset;
1928
1955
  idx_t total_written;
@@ -2224,14 +2251,14 @@ struct TemplatedValidityData {
2224
2251
  static constexpr const V MAX_ENTRY = ~V(0);
2225
2252
 
2226
2253
  public:
2227
- explicit TemplatedValidityData(idx_t count) {
2254
+ inline explicit TemplatedValidityData(idx_t count) {
2228
2255
  auto entry_count = EntryCount(count);
2229
2256
  owned_data = unique_ptr<V[]>(new V[entry_count]);
2230
2257
  for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
2231
2258
  owned_data[entry_idx] = MAX_ENTRY;
2232
2259
  }
2233
2260
  }
2234
- TemplatedValidityData(const V *validity_mask, idx_t count) {
2261
+ inline TemplatedValidityData(const V *validity_mask, idx_t count) {
2235
2262
  D_ASSERT(validity_mask);
2236
2263
  auto entry_count = EntryCount(count);
2237
2264
  owned_data = unique_ptr<V[]>(new V[entry_count]);
@@ -2267,14 +2294,14 @@ public:
2267
2294
  static constexpr const int STANDARD_MASK_SIZE = STANDARD_ENTRY_COUNT * sizeof(validity_t);
2268
2295
 
2269
2296
  public:
2270
- TemplatedValidityMask() : validity_mask(nullptr) {
2297
+ inline TemplatedValidityMask() : validity_mask(nullptr) {
2271
2298
  }
2272
- explicit TemplatedValidityMask(idx_t max_count) {
2299
+ inline explicit TemplatedValidityMask(idx_t max_count) {
2273
2300
  Initialize(max_count);
2274
2301
  }
2275
- explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
2302
+ inline explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
2276
2303
  }
2277
- TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
2304
+ inline TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
2278
2305
  Copy(original, count);
2279
2306
  }
2280
2307
 
@@ -2284,7 +2311,7 @@ public:
2284
2311
  inline bool AllValid() const {
2285
2312
  return !validity_mask;
2286
2313
  }
2287
- bool CheckAllValid(idx_t count) const {
2314
+ inline bool CheckAllValid(idx_t count) const {
2288
2315
  if (AllValid()) {
2289
2316
  return true;
2290
2317
  }
@@ -2296,7 +2323,7 @@ public:
2296
2323
  return valid_count == entry_count;
2297
2324
  }
2298
2325
 
2299
- bool CheckAllValid(idx_t to, idx_t from) const {
2326
+ inline bool CheckAllValid(idx_t to, idx_t from) const {
2300
2327
  if (AllValid()) {
2301
2328
  return true;
2302
2329
  }
@@ -2311,7 +2338,7 @@ public:
2311
2338
  inline V *GetData() const {
2312
2339
  return validity_mask;
2313
2340
  }
2314
- void Reset() {
2341
+ inline void Reset() {
2315
2342
  validity_mask = nullptr;
2316
2343
  validity_data.reset();
2317
2344
  }
@@ -2437,19 +2464,19 @@ public:
2437
2464
  }
2438
2465
 
2439
2466
  public:
2440
- void Initialize(validity_t *validity) {
2467
+ inline void Initialize(validity_t *validity) {
2441
2468
  validity_data.reset();
2442
2469
  validity_mask = validity;
2443
2470
  }
2444
- void Initialize(const TemplatedValidityMask &other) {
2471
+ inline void Initialize(const TemplatedValidityMask &other) {
2445
2472
  validity_mask = other.validity_mask;
2446
2473
  validity_data = other.validity_data;
2447
2474
  }
2448
- void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
2475
+ inline void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
2449
2476
  validity_data = make_buffer<ValidityBuffer>(count);
2450
2477
  validity_mask = validity_data->owned_data.get();
2451
2478
  }
2452
- void Copy(const TemplatedValidityMask &other, idx_t count) {
2479
+ inline void Copy(const TemplatedValidityMask &other, idx_t count) {
2453
2480
  if (other.AllValid()) {
2454
2481
  validity_data = nullptr;
2455
2482
  validity_mask = nullptr;
@@ -2466,21 +2493,21 @@ protected:
2466
2493
 
2467
2494
  struct ValidityMask : public TemplatedValidityMask<validity_t> {
2468
2495
  public:
2469
- ValidityMask() : TemplatedValidityMask(nullptr) {
2496
+ inline ValidityMask() : TemplatedValidityMask(nullptr) {
2470
2497
  }
2471
- explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
2498
+ inline explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
2472
2499
  }
2473
- explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
2500
+ inline explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
2474
2501
  }
2475
- ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
2502
+ inline ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
2476
2503
  }
2477
2504
 
2478
2505
  public:
2479
- void Resize(idx_t old_size, idx_t new_size);
2506
+ DUCKDB_API void Resize(idx_t old_size, idx_t new_size);
2480
2507
 
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;
2508
+ DUCKDB_API void Slice(const ValidityMask &other, idx_t offset);
2509
+ DUCKDB_API void Combine(const ValidityMask &other, idx_t count);
2510
+ DUCKDB_API string ToString(idx_t count) const;
2484
2511
  };
2485
2512
 
2486
2513
  } // namespace duckdb
@@ -2512,25 +2539,25 @@ class Value {
2512
2539
 
2513
2540
  public:
2514
2541
  //! Create an empty NULL value of the specified type
2515
- explicit Value(LogicalType type = LogicalType::SQLNULL);
2542
+ DUCKDB_API explicit Value(LogicalType type = LogicalType::SQLNULL);
2516
2543
  //! Create an INTEGER value
2517
- Value(int32_t val); // NOLINT: Allow implicit conversion from `int32_t`
2544
+ DUCKDB_API Value(int32_t val); // NOLINT: Allow implicit conversion from `int32_t`
2518
2545
  //! Create a BIGINT value
2519
- Value(int64_t val); // NOLINT: Allow implicit conversion from `int64_t`
2546
+ DUCKDB_API Value(int64_t val); // NOLINT: Allow implicit conversion from `int64_t`
2520
2547
  //! Create a FLOAT value
2521
- Value(float val); // NOLINT: Allow implicit conversion from `float`
2548
+ DUCKDB_API Value(float val); // NOLINT: Allow implicit conversion from `float`
2522
2549
  //! Create a DOUBLE value
2523
- Value(double val); // NOLINT: Allow implicit conversion from `double`
2550
+ DUCKDB_API Value(double val); // NOLINT: Allow implicit conversion from `double`
2524
2551
  //! Create a VARCHAR value
2525
- Value(const char *val); // NOLINT: Allow implicit conversion from `const char *`
2552
+ DUCKDB_API Value(const char *val); // NOLINT: Allow implicit conversion from `const char *`
2526
2553
  //! Create a NULL value
2527
- Value(std::nullptr_t val); // NOLINT: Allow implicit conversion from `nullptr_t`
2554
+ DUCKDB_API Value(std::nullptr_t val); // NOLINT: Allow implicit conversion from `nullptr_t`
2528
2555
  //! Create a VARCHAR value
2529
- Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2556
+ DUCKDB_API Value(string_t val); // NOLINT: Allow implicit conversion from `string_t`
2530
2557
  //! Create a VARCHAR value
2531
- Value(string val); // NOLINT: Allow implicit conversion from `string`
2558
+ DUCKDB_API Value(string val); // NOLINT: Allow implicit conversion from `string`
2532
2559
 
2533
- const LogicalType &type() const {
2560
+ inline const LogicalType &type() const {
2534
2561
  return type_;
2535
2562
  }
2536
2563
 
@@ -2572,19 +2599,22 @@ public:
2572
2599
  DUCKDB_API static Value POINTER(uintptr_t value);
2573
2600
  //! Create a date Value from a specified date
2574
2601
  DUCKDB_API static Value DATE(date_t date);
2602
+ DUCKDB_API static Value DATETZ(date_t date);
2575
2603
  //! Create a date Value from a specified date
2576
2604
  DUCKDB_API static Value DATE(int32_t year, int32_t month, int32_t day);
2577
2605
  //! Create a time Value from a specified time
2578
2606
  DUCKDB_API static Value TIME(dtime_t time);
2607
+ DUCKDB_API static Value TIMETZ(dtime_t time);
2579
2608
  //! Create a time Value from a specified time
2580
2609
  DUCKDB_API static Value TIME(int32_t hour, int32_t min, int32_t sec, int32_t micros);
2581
2610
  //! Create a timestamp Value from a specified date/time combination
2582
2611
  DUCKDB_API static Value TIMESTAMP(date_t date, dtime_t time);
2583
2612
  //! Create a timestamp Value from a specified timestamp
2584
2613
  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);
2614
+ DUCKDB_API static Value TIMESTAMPNS(timestamp_t timestamp);
2615
+ DUCKDB_API static Value TIMESTAMPMS(timestamp_t timestamp);
2616
+ DUCKDB_API static Value TIMESTAMPSEC(timestamp_t timestamp);
2617
+ DUCKDB_API static Value TIMESTAMPTZ(timestamp_t timestamp);
2588
2618
  //! Create a timestamp Value from a specified timestamp in separate values
2589
2619
  DUCKDB_API static Value TIMESTAMP(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, int32_t sec,
2590
2620
  int32_t micros);
@@ -2605,8 +2635,11 @@ public:
2605
2635
  DUCKDB_API static Value DOUBLE(double value);
2606
2636
  //! Create a struct value with given list of entries
2607
2637
  DUCKDB_API static Value STRUCT(child_list_t<Value> values);
2608
- //! Create a list value with the given entries
2638
+ //! Create a list value with the given entries, list type is inferred from children
2639
+ //! Cannot be called with an empty list, use either EMPTYLIST or LIST with a type instead
2609
2640
  DUCKDB_API static Value LIST(vector<Value> values);
2641
+ //! Create a list value with the given entries
2642
+ DUCKDB_API static Value LIST(LogicalType child_type, vector<Value> values);
2610
2643
  //! Create an empty list with the specified type
2611
2644
  DUCKDB_API static Value EMPTYLIST(LogicalType child_type);
2612
2645
  //! Creat a map value from a (key, value) pair
@@ -2661,32 +2694,32 @@ public:
2661
2694
  //===--------------------------------------------------------------------===//
2662
2695
  // Numeric Operators
2663
2696
  //===--------------------------------------------------------------------===//
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;
2697
+ DUCKDB_API Value operator+(const Value &rhs) const;
2698
+ DUCKDB_API Value operator-(const Value &rhs) const;
2699
+ DUCKDB_API Value operator*(const Value &rhs) const;
2700
+ DUCKDB_API Value operator/(const Value &rhs) const;
2701
+ DUCKDB_API Value operator%(const Value &rhs) const;
2669
2702
 
2670
2703
  //===--------------------------------------------------------------------===//
2671
2704
  // Comparison Operators
2672
2705
  //===--------------------------------------------------------------------===//
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);
2706
+ DUCKDB_API bool operator==(const Value &rhs) const;
2707
+ DUCKDB_API bool operator!=(const Value &rhs) const;
2708
+ DUCKDB_API bool operator<(const Value &rhs) const;
2709
+ DUCKDB_API bool operator>(const Value &rhs) const;
2710
+ DUCKDB_API bool operator<=(const Value &rhs) const;
2711
+ DUCKDB_API bool operator>=(const Value &rhs) const;
2712
+
2713
+ DUCKDB_API bool operator==(const int64_t &rhs) const;
2714
+ DUCKDB_API bool operator!=(const int64_t &rhs) const;
2715
+ DUCKDB_API bool operator<(const int64_t &rhs) const;
2716
+ DUCKDB_API bool operator>(const int64_t &rhs) const;
2717
+ DUCKDB_API bool operator<=(const int64_t &rhs) const;
2718
+ DUCKDB_API bool operator>=(const int64_t &rhs) const;
2719
+
2720
+ DUCKDB_API static bool FloatIsValid(float value);
2721
+ DUCKDB_API static bool DoubleIsValid(double value);
2722
+ DUCKDB_API static bool StringIsValid(const char *str, idx_t length);
2690
2723
  static bool StringIsValid(const string &str) {
2691
2724
  return StringIsValid(str.c_str(), str.size());
2692
2725
  }
@@ -2698,13 +2731,13 @@ public:
2698
2731
 
2699
2732
  //! Returns true if the values are (approximately) equivalent. Note this is NOT the SQL equivalence. For this
2700
2733
  //! 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);
2734
+ DUCKDB_API static bool ValuesAreEqual(const Value &result_value, const Value &value);
2702
2735
 
2703
2736
  friend std::ostream &operator<<(std::ostream &out, const Value &val) {
2704
2737
  out << val.ToString();
2705
2738
  return out;
2706
2739
  }
2707
- void Print() const;
2740
+ DUCKDB_API void Print() const;
2708
2741
 
2709
2742
  private:
2710
2743
  //! The logical of the value
@@ -3283,69 +3316,69 @@ class Vector {
3283
3316
 
3284
3317
  public:
3285
3318
  //! Create a vector that references the other vector
3286
- explicit Vector(Vector &other);
3319
+ DUCKDB_API explicit Vector(Vector &other);
3287
3320
  //! Create a vector that slices another vector
3288
- explicit Vector(Vector &other, const SelectionVector &sel, idx_t count);
3321
+ DUCKDB_API explicit Vector(Vector &other, const SelectionVector &sel, idx_t count);
3289
3322
  //! Create a vector that slices another vector starting from a specific offset
3290
- explicit Vector(Vector &other, idx_t offset);
3323
+ DUCKDB_API explicit Vector(Vector &other, idx_t offset);
3291
3324
  //! Create a vector of size one holding the passed on value
3292
- explicit Vector(const Value &value);
3325
+ DUCKDB_API explicit Vector(const Value &value);
3293
3326
  //! Create a vector of size tuple_count (non-standard)
3294
- explicit Vector(LogicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3327
+ DUCKDB_API explicit Vector(LogicalType type, idx_t capacity = STANDARD_VECTOR_SIZE);
3295
3328
  //! Create an empty standard vector with a type, equivalent to calling Vector(type, true, false)
3296
- explicit Vector(const VectorCache &cache);
3329
+ DUCKDB_API explicit Vector(const VectorCache &cache);
3297
3330
  //! Create a non-owning vector that references the specified data
3298
- Vector(LogicalType type, data_ptr_t dataptr);
3331
+ DUCKDB_API Vector(LogicalType type, data_ptr_t dataptr);
3299
3332
  //! Create an owning vector that holds at most STANDARD_VECTOR_SIZE entries.
3300
3333
  /*!
3301
3334
  Create a new vector
3302
3335
  If create_data is true, the vector will be an owning empty vector.
3303
3336
  If zero_data is true, the allocated data will be zero-initialized.
3304
3337
  */
3305
- Vector(LogicalType type, bool create_data, bool zero_data, idx_t capacity = STANDARD_VECTOR_SIZE);
3338
+ DUCKDB_API Vector(LogicalType type, bool create_data, bool zero_data, idx_t capacity = STANDARD_VECTOR_SIZE);
3306
3339
  // implicit copying of Vectors is not allowed
3307
- Vector(const Vector &) = delete;
3340
+ DUCKDB_API Vector(const Vector &) = delete;
3308
3341
  // but moving of vectors is allowed
3309
- Vector(Vector &&other) noexcept;
3342
+ DUCKDB_API Vector(Vector &&other) noexcept;
3310
3343
 
3311
3344
  public:
3312
3345
  //! Create a vector that references the specified value.
3313
- void Reference(const Value &value);
3346
+ DUCKDB_API void Reference(const Value &value);
3314
3347
  //! Causes this vector to reference the data held by the other vector.
3315
3348
  //! The type of the "other" vector should match the type of this vector
3316
- void Reference(Vector &other);
3349
+ DUCKDB_API void Reference(Vector &other);
3317
3350
  //! Reinterpret the data of the other vector as the type of this vector
3318
3351
  //! Note that this takes the data of the other vector as-is and places it in this vector
3319
3352
  //! Without changing the type of this vector
3320
- void Reinterpret(Vector &other);
3353
+ DUCKDB_API void Reinterpret(Vector &other);
3321
3354
 
3322
3355
  //! Causes this vector to reference the data held by the other vector, changes the type if required.
3323
- void ReferenceAndSetType(Vector &other);
3356
+ DUCKDB_API void ReferenceAndSetType(Vector &other);
3324
3357
 
3325
3358
  //! Resets a vector from a vector cache.
3326
3359
  //! This turns the vector back into an empty FlatVector with STANDARD_VECTOR_SIZE entries.
3327
3360
  //! The VectorCache is used so this can be done without requiring any allocations.
3328
- void ResetFromCache(const VectorCache &cache);
3361
+ DUCKDB_API void ResetFromCache(const VectorCache &cache);
3329
3362
 
3330
3363
  //! Creates a reference to a slice of the other vector
3331
- void Slice(Vector &other, idx_t offset);
3364
+ DUCKDB_API void Slice(Vector &other, idx_t offset);
3332
3365
  //! Creates a reference to a slice of the other vector
3333
- void Slice(Vector &other, const SelectionVector &sel, idx_t count);
3366
+ DUCKDB_API void Slice(Vector &other, const SelectionVector &sel, idx_t count);
3334
3367
  //! Turns the vector into a dictionary vector with the specified dictionary
3335
- void Slice(const SelectionVector &sel, idx_t count);
3368
+ DUCKDB_API void Slice(const SelectionVector &sel, idx_t count);
3336
3369
  //! 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);
3370
+ DUCKDB_API void Slice(const SelectionVector &sel, idx_t count, SelCache &cache);
3338
3371
 
3339
3372
  //! Creates the data of this vector with the specified type. Any data that
3340
3373
  //! is currently in the vector is destroyed.
3341
- void Initialize(bool zero_data = false, idx_t capacity = STANDARD_VECTOR_SIZE);
3374
+ DUCKDB_API void Initialize(bool zero_data = false, idx_t capacity = STANDARD_VECTOR_SIZE);
3342
3375
 
3343
3376
  //! Converts this Vector to a printable string representation
3344
- string ToString(idx_t count) const;
3345
- void Print(idx_t count);
3377
+ DUCKDB_API string ToString(idx_t count) const;
3378
+ DUCKDB_API void Print(idx_t count);
3346
3379
 
3347
- string ToString() const;
3348
- void Print();
3380
+ DUCKDB_API string ToString() const;
3381
+ DUCKDB_API void Print();
3349
3382
 
3350
3383
  //! Flatten the vector, removing any compression and turning it into a FLAT_VECTOR
3351
3384
  DUCKDB_API void Normalify(idx_t count);
@@ -3354,31 +3387,31 @@ public:
3354
3387
  DUCKDB_API void Orrify(idx_t count, VectorData &data);
3355
3388
 
3356
3389
  //! Turn the vector into a sequence vector
3357
- void Sequence(int64_t start, int64_t increment);
3390
+ DUCKDB_API void Sequence(int64_t start, int64_t increment);
3358
3391
 
3359
3392
  //! Verify that the Vector is in a consistent, not corrupt state. DEBUG
3360
3393
  //! 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);
3394
+ DUCKDB_API void Verify(idx_t count);
3395
+ DUCKDB_API void Verify(const SelectionVector &sel, idx_t count);
3396
+ DUCKDB_API void UTFVerify(idx_t count);
3397
+ DUCKDB_API void UTFVerify(const SelectionVector &sel, idx_t count);
3365
3398
 
3366
3399
  //! Returns the [index] element of the Vector as a Value.
3367
- Value GetValue(idx_t index) const;
3400
+ DUCKDB_API Value GetValue(idx_t index) const;
3368
3401
  //! Sets the [index] element of the Vector to the specified Value.
3369
- void SetValue(idx_t index, const Value &val);
3402
+ DUCKDB_API void SetValue(idx_t index, const Value &val);
3370
3403
 
3371
- void SetAuxiliary(buffer_ptr<VectorBuffer> new_buffer) {
3404
+ inline void SetAuxiliary(buffer_ptr<VectorBuffer> new_buffer) {
3372
3405
  auxiliary = std::move(new_buffer);
3373
3406
  };
3374
3407
 
3375
3408
  //! This functions resizes the vector
3376
- void Resize(idx_t cur_size, idx_t new_size);
3409
+ DUCKDB_API void Resize(idx_t cur_size, idx_t new_size);
3377
3410
 
3378
3411
  //! Serializes a Vector to a stand-alone binary blob
3379
- void Serialize(idx_t count, Serializer &serializer);
3412
+ DUCKDB_API void Serialize(idx_t count, Serializer &serializer);
3380
3413
  //! Deserializes a blob back into a Vector
3381
- void Deserialize(idx_t count, Deserializer &source);
3414
+ DUCKDB_API void Deserialize(idx_t count, Deserializer &source);
3382
3415
 
3383
3416
  // Getters
3384
3417
  inline VectorType GetVectorType() const {
@@ -3391,11 +3424,11 @@ public:
3391
3424
  return data;
3392
3425
  }
3393
3426
 
3394
- buffer_ptr<VectorBuffer> GetAuxiliary() {
3427
+ inline buffer_ptr<VectorBuffer> GetAuxiliary() {
3395
3428
  return auxiliary;
3396
3429
  }
3397
3430
 
3398
- buffer_ptr<VectorBuffer> GetBuffer() {
3431
+ inline buffer_ptr<VectorBuffer> GetBuffer() {
3399
3432
  return buffer;
3400
3433
  }
3401
3434
 
@@ -3646,27 +3679,27 @@ class VectorCache;
3646
3679
  class DataChunk {
3647
3680
  public:
3648
3681
  //! Creates an empty DataChunk
3649
- DataChunk();
3650
- ~DataChunk();
3682
+ DUCKDB_API DataChunk();
3683
+ DUCKDB_API ~DataChunk();
3651
3684
 
3652
3685
  //! The vectors owned by the DataChunk.
3653
3686
  vector<Vector> data;
3654
3687
 
3655
3688
  public:
3656
- DUCKDB_API idx_t size() const {
3689
+ inline idx_t size() const { // NOLINT
3657
3690
  return count;
3658
3691
  }
3659
- DUCKDB_API idx_t ColumnCount() const {
3692
+ inline idx_t ColumnCount() const {
3660
3693
  return data.size();
3661
3694
  }
3662
- void SetCardinality(idx_t count_p) {
3695
+ inline void SetCardinality(idx_t count_p) {
3663
3696
  D_ASSERT(count_p <= capacity);
3664
3697
  this->count = count_p;
3665
3698
  }
3666
- void SetCardinality(const DataChunk &other) {
3699
+ inline void SetCardinality(const DataChunk &other) {
3667
3700
  this->count = other.size();
3668
3701
  }
3669
- void SetCapacity(const DataChunk &other) {
3702
+ inline void SetCapacity(const DataChunk &other) {
3670
3703
  this->capacity = other.capacity;
3671
3704
  }
3672
3705
 
@@ -3682,9 +3715,9 @@ public:
3682
3715
  //! This will create one vector of the specified type for each LogicalType in the
3683
3716
  //! types list. The vector will be referencing vector to the data owned by
3684
3717
  //! the DataChunk.
3685
- void Initialize(const vector<LogicalType> &types);
3718
+ DUCKDB_API void Initialize(const vector<LogicalType> &types);
3686
3719
  //! 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);
3720
+ DUCKDB_API void InitializeEmpty(const vector<LogicalType> &types);
3688
3721
  //! Append the other DataChunk to this one. The column count and types of
3689
3722
  //! the two DataChunks have to match exactly. Throws an exception if there
3690
3723
  //! is not enough space in the chunk and resize is not allowed.
@@ -5422,7 +5455,7 @@ public:
5422
5455
  }
5423
5456
 
5424
5457
  //! The location in the query (if any)
5425
- idx_t query_location = INVALID_INDEX;
5458
+ idx_t query_location = DConstants::INVALID_INDEX;
5426
5459
 
5427
5460
  public:
5428
5461
  bool IsAggregate() const override;
@@ -5491,11 +5524,8 @@ namespace duckdb {
5491
5524
  //! A column of a table.
5492
5525
  class ColumnDefinition {
5493
5526
  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
- }
5527
+ DUCKDB_API ColumnDefinition(string name, LogicalType type);
5528
+ DUCKDB_API ColumnDefinition(string name, LogicalType type, unique_ptr<ParsedExpression> default_value);
5499
5529
 
5500
5530
  //! The name of the entry
5501
5531
  string name;
@@ -5509,10 +5539,10 @@ public:
5509
5539
  CompressionType compression_type = CompressionType::COMPRESSION_AUTO;
5510
5540
 
5511
5541
  public:
5512
- ColumnDefinition Copy() const;
5542
+ DUCKDB_API ColumnDefinition Copy() const;
5513
5543
 
5514
- void Serialize(Serializer &serializer) const;
5515
- static ColumnDefinition Deserialize(Deserializer &source);
5544
+ DUCKDB_API void Serialize(Serializer &serializer) const;
5545
+ DUCKDB_API static ColumnDefinition Deserialize(Deserializer &source);
5516
5546
  };
5517
5547
 
5518
5548
  } // namespace duckdb
@@ -5538,24 +5568,11 @@ class TableFunction;
5538
5568
  struct PragmaInfo;
5539
5569
 
5540
5570
  struct FunctionData {
5541
- virtual ~FunctionData() {
5542
- }
5571
+ DUCKDB_API virtual ~FunctionData();
5543
5572
 
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
- }
5573
+ DUCKDB_API virtual unique_ptr<FunctionData> Copy();
5574
+ DUCKDB_API virtual bool Equals(FunctionData &other);
5575
+ DUCKDB_API static bool Equals(FunctionData *left, FunctionData *right);
5559
5576
  };
5560
5577
 
5561
5578
  struct TableFunctionData : public FunctionData {
@@ -5571,10 +5588,8 @@ struct FunctionParameters {
5571
5588
  //! Function is the base class used for any type of function (scalar, aggregate or simple function)
5572
5589
  class Function {
5573
5590
  public:
5574
- explicit Function(string name) : name(name) {
5575
- }
5576
- virtual ~Function() {
5577
- }
5591
+ DUCKDB_API explicit Function(string name);
5592
+ DUCKDB_API virtual ~Function();
5578
5593
 
5579
5594
  //! The name of the function
5580
5595
  string name;
@@ -5590,35 +5605,33 @@ public:
5590
5605
  const unordered_map<string, LogicalType> &named_parameters);
5591
5606
 
5592
5607
  //! 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);
5608
+ //! returns DConstants::INVALID_INDEX and sets error if none could be found
5609
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5610
+ vector<LogicalType> &arguments, string &error);
5611
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<ScalarFunction> &functions,
5612
+ vector<unique_ptr<Expression>> &arguments, string &error);
5598
5613
  //! 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);
5614
+ //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
5615
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5616
+ vector<LogicalType> &arguments, string &error);
5617
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<AggregateFunction> &functions,
5618
+ vector<unique_ptr<Expression>> &arguments, string &error);
5604
5619
  //! 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);
5620
+ //! function, returns DConstants::INVALID_INDEX and sets error if none could be found
5621
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5622
+ vector<LogicalType> &arguments, string &error);
5623
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<TableFunction> &functions,
5624
+ vector<unique_ptr<Expression>> &arguments, string &error);
5610
5625
  //! 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);
5626
+ DUCKDB_API static idx_t BindFunction(const string &name, vector<PragmaFunction> &functions, PragmaInfo &info,
5627
+ string &error);
5612
5628
  };
5613
5629
 
5614
5630
  class SimpleFunction : public Function {
5615
5631
  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
- }
5632
+ DUCKDB_API SimpleFunction(string name, vector<LogicalType> arguments,
5633
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5634
+ DUCKDB_API ~SimpleFunction() override;
5622
5635
 
5623
5636
  //! The set of arguments of the function
5624
5637
  vector<LogicalType> arguments;
@@ -5627,50 +5640,34 @@ public:
5627
5640
  LogicalType varargs;
5628
5641
 
5629
5642
  public:
5630
- virtual string ToString() {
5631
- return Function::CallToString(name, arguments);
5632
- }
5643
+ DUCKDB_API virtual string ToString();
5633
5644
 
5634
- bool HasVarArgs() const {
5635
- return varargs.id() != LogicalTypeId::INVALID;
5636
- }
5645
+ DUCKDB_API bool HasVarArgs() const;
5637
5646
  };
5638
5647
 
5639
5648
  class SimpleNamedParameterFunction : public SimpleFunction {
5640
5649
  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
- }
5650
+ DUCKDB_API SimpleNamedParameterFunction(string name, vector<LogicalType> arguments,
5651
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5652
+ DUCKDB_API ~SimpleNamedParameterFunction() override;
5647
5653
 
5648
5654
  //! The named parameters of the function
5649
5655
  unordered_map<string, LogicalType> named_parameters;
5650
5656
 
5651
5657
  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
- }
5658
+ DUCKDB_API string ToString() override;
5659
+ DUCKDB_API bool HasNamedParameters();
5659
5660
 
5660
- void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5661
- unordered_map<string, Value> &named_parameters,
5662
- vector<unique_ptr<ParsedExpression>> &children);
5661
+ DUCKDB_API void EvaluateInputParameters(vector<LogicalType> &arguments, vector<Value> &parameters,
5662
+ unordered_map<string, Value> &named_parameters,
5663
+ vector<unique_ptr<ParsedExpression>> &children);
5663
5664
  };
5664
5665
 
5665
5666
  class BaseScalarFunction : public SimpleFunction {
5666
5667
  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
- }
5668
+ DUCKDB_API BaseScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
5669
+ bool has_side_effects, LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
5670
+ DUCKDB_API ~BaseScalarFunction() override;
5674
5671
 
5675
5672
  //! Return type of the function
5676
5673
  LogicalType return_type;
@@ -5679,14 +5676,12 @@ public:
5679
5676
  bool has_side_effects;
5680
5677
 
5681
5678
  public:
5682
- hash_t Hash() const;
5679
+ DUCKDB_API hash_t Hash() const;
5683
5680
 
5684
5681
  //! Cast a set of expressions to the arguments of this function
5685
- void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
5682
+ DUCKDB_API void CastToFunctionArguments(vector<unique_ptr<Expression>> &children);
5686
5683
 
5687
- string ToString() override {
5688
- return Function::CallToString(name, arguments, return_type);
5689
- }
5684
+ DUCKDB_API string ToString() override;
5690
5685
  };
5691
5686
 
5692
5687
  class BuiltinFunctions {
@@ -6050,7 +6045,7 @@ public:
6050
6045
  static string ToString(const interval_t &val);
6051
6046
 
6052
6047
  //! Convert milliseconds to a normalised interval
6053
- static interval_t FromMicro(int64_t micros);
6048
+ DUCKDB_API static interval_t FromMicro(int64_t micros);
6054
6049
 
6055
6050
  //! Get Interval in milliseconds
6056
6051
  static int64_t GetMilli(const interval_t &val);
@@ -6408,23 +6403,17 @@ typedef void (*dependency_function_t)(BoundFunctionExpression &expr, unordered_s
6408
6403
 
6409
6404
  class ScalarFunction : public BaseScalarFunction {
6410
6405
  public:
6411
- ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6412
- bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6413
- dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6414
- init_local_state_t init_local_state = nullptr,
6415
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
6416
- : BaseScalarFunction(name, arguments, return_type, has_side_effects, varargs), function(function), bind(bind),
6417
- init_local_state(init_local_state), dependency(dependency), statistics(statistics) {
6418
- }
6406
+ DUCKDB_API ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type,
6407
+ scalar_function_t function, bool has_side_effects = false,
6408
+ bind_scalar_function_t bind = nullptr, dependency_function_t dependency = nullptr,
6409
+ function_statistics_t statistics = nullptr, init_local_state_t init_local_state = nullptr,
6410
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
6419
6411
 
6420
- ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6421
- bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6422
- dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6423
- init_local_state_t init_local_state = nullptr,
6424
- LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
6425
- : ScalarFunction(string(), arguments, return_type, function, has_side_effects, bind, dependency, statistics,
6426
- init_local_state, varargs) {
6427
- }
6412
+ DUCKDB_API ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
6413
+ bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
6414
+ dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
6415
+ init_local_state_t init_local_state = nullptr,
6416
+ LogicalType varargs = LogicalType(LogicalTypeId::INVALID));
6428
6417
 
6429
6418
  //! The main scalar function to execute
6430
6419
  scalar_function_t function;
@@ -6432,78 +6421,35 @@ public:
6432
6421
  bind_scalar_function_t bind;
6433
6422
  //! Init thread local state for the function (if any)
6434
6423
  init_local_state_t init_local_state;
6435
- // The dependency function (if any)
6424
+ //! The dependency function (if any)
6436
6425
  dependency_function_t dependency;
6437
6426
  //! The statistics propagation function (if any)
6438
6427
  function_statistics_t statistics;
6439
6428
 
6440
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context, const string &schema,
6441
- const string &name,
6442
- vector<unique_ptr<Expression>> children,
6443
- string &error, bool is_operator = false);
6444
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6445
- ScalarFunctionCatalogEntry &function,
6446
- vector<unique_ptr<Expression>> children,
6447
- string &error, bool is_operator = false);
6448
-
6449
- static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context, ScalarFunction bound_function,
6450
- vector<unique_ptr<Expression>> children,
6451
- bool is_operator = false);
6429
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6430
+ const string &schema, const string &name,
6431
+ vector<unique_ptr<Expression>> children,
6432
+ string &error, bool is_operator = false);
6433
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6434
+ ScalarFunctionCatalogEntry &function,
6435
+ vector<unique_ptr<Expression>> children,
6436
+ string &error, bool is_operator = false);
6452
6437
 
6453
- bool operator==(const ScalarFunction &rhs) const {
6454
- return CompareScalarFunctionT(rhs.function) && bind == rhs.bind && dependency == rhs.dependency &&
6455
- statistics == rhs.statistics;
6456
- }
6457
- bool operator!=(const ScalarFunction &rhs) const {
6458
- return !(*this == rhs);
6459
- }
6438
+ DUCKDB_API static unique_ptr<BoundFunctionExpression> BindScalarFunction(ClientContext &context,
6439
+ ScalarFunction bound_function,
6440
+ vector<unique_ptr<Expression>> children,
6441
+ bool is_operator = false);
6460
6442
 
6461
- bool Equal(const ScalarFunction &rhs) const {
6462
- // number of types
6463
- if (this->arguments.size() != rhs.arguments.size()) {
6464
- return false;
6465
- }
6466
- // argument types
6467
- for (idx_t i = 0; i < this->arguments.size(); ++i) {
6468
- if (this->arguments[i] != rhs.arguments[i]) {
6469
- return false;
6470
- }
6471
- }
6472
- // return type
6473
- if (this->return_type != rhs.return_type) {
6474
- return false;
6475
- }
6476
- // varargs
6477
- if (this->varargs != rhs.varargs) {
6478
- return false;
6479
- }
6443
+ DUCKDB_API bool operator==(const ScalarFunction &rhs) const;
6444
+ DUCKDB_API bool operator!=(const ScalarFunction &rhs) const;
6480
6445
 
6481
- return true; // they are equal
6482
- }
6446
+ DUCKDB_API bool Equal(const ScalarFunction &rhs) const;
6483
6447
 
6484
6448
  private:
6485
- bool CompareScalarFunctionT(const scalar_function_t other) const {
6486
- typedef void(scalar_function_ptr_t)(DataChunk &, ExpressionState &, Vector &);
6487
-
6488
- auto func_ptr = (scalar_function_ptr_t **)function.template target<scalar_function_ptr_t *>();
6489
- auto other_ptr = (scalar_function_ptr_t **)other.template target<scalar_function_ptr_t *>();
6490
-
6491
- // Case the functions were created from lambdas the target will return a nullptr
6492
- if (!func_ptr && !other_ptr) {
6493
- return true;
6494
- }
6495
- if (func_ptr == nullptr || other_ptr == nullptr) {
6496
- // scalar_function_t (std::functions) from lambdas cannot be compared
6497
- return false;
6498
- }
6499
- return ((size_t)*func_ptr == (size_t)*other_ptr);
6500
- }
6449
+ bool CompareScalarFunctionT(const scalar_function_t &other) const;
6501
6450
 
6502
6451
  public:
6503
- static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result) {
6504
- D_ASSERT(input.ColumnCount() >= 1);
6505
- result.Reference(input.data[0]);
6506
- }
6452
+ DUCKDB_API static void NopFunction(DataChunk &input, ExpressionState &state, Vector &result);
6507
6453
 
6508
6454
  template <class TA, class TR, class OP>
6509
6455
  static void UnaryFunction(DataChunk &input, ExpressionState &state, Vector &result) {
@@ -6954,12 +6900,12 @@ public:
6954
6900
 
6955
6901
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
6956
6902
  static void UnaryWindow(Vector &input, FunctionData *bind_data, data_ptr_t state, const FrameBounds &frame,
6957
- const FrameBounds &prev, Vector &result, idx_t rid) {
6903
+ const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
6958
6904
 
6959
- auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - MinValue(frame.first, prev.first);
6905
+ auto idata = FlatVector::GetData<const INPUT_TYPE>(input) - bias;
6960
6906
  const auto &ivalid = FlatVector::Validity(input);
6961
6907
  OP::template Window<STATE, INPUT_TYPE, RESULT_TYPE>(idata, ivalid, bind_data, (STATE *)state, frame, prev,
6962
- result, rid);
6908
+ result, rid, bias);
6963
6909
  }
6964
6910
 
6965
6911
  template <class STATE_TYPE, class OP>
@@ -7059,7 +7005,12 @@ enum class OrderByNullType : uint8_t { INVALID = 0, ORDER_DEFAULT = 1, NULLS_FIR
7059
7005
 
7060
7006
  namespace duckdb {
7061
7007
 
7062
- enum ResultModifierType : uint8_t { LIMIT_MODIFIER = 1, ORDER_MODIFIER = 2, DISTINCT_MODIFIER = 3 };
7008
+ enum ResultModifierType : uint8_t {
7009
+ LIMIT_MODIFIER = 1,
7010
+ ORDER_MODIFIER = 2,
7011
+ DISTINCT_MODIFIER = 3,
7012
+ LIMIT_PERCENT_MODIFIER = 4
7013
+ };
7063
7014
 
7064
7015
  //! A ResultModifier
7065
7016
  class ResultModifier {
@@ -7149,6 +7100,23 @@ public:
7149
7100
  static unique_ptr<ResultModifier> Deserialize(Deserializer &source);
7150
7101
  };
7151
7102
 
7103
+ class LimitPercentModifier : public ResultModifier {
7104
+ public:
7105
+ LimitPercentModifier() : ResultModifier(ResultModifierType::LIMIT_PERCENT_MODIFIER) {
7106
+ }
7107
+
7108
+ //! LIMIT %
7109
+ unique_ptr<ParsedExpression> limit;
7110
+ //! OFFSET
7111
+ unique_ptr<ParsedExpression> offset;
7112
+
7113
+ public:
7114
+ bool Equals(const ResultModifier *other) const override;
7115
+ unique_ptr<ResultModifier> Copy() override;
7116
+ void Serialize(Serializer &serializer) override;
7117
+ static unique_ptr<ResultModifier> Deserialize(Deserializer &source);
7118
+ };
7119
+
7152
7120
  } // namespace duckdb
7153
7121
 
7154
7122
  //===----------------------------------------------------------------------===//
@@ -7343,7 +7311,7 @@ class SQLStatement;
7343
7311
 
7344
7312
  class QueryErrorContext {
7345
7313
  public:
7346
- explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = INVALID_INDEX)
7314
+ explicit QueryErrorContext(SQLStatement *statement_ = nullptr, idx_t query_location_ = DConstants::INVALID_INDEX)
7347
7315
  : statement(statement_), query_location(query_location_) {
7348
7316
  }
7349
7317
 
@@ -7388,6 +7356,7 @@ struct CreateViewInfo;
7388
7356
  struct CreateSequenceInfo;
7389
7357
  struct CreateCollationInfo;
7390
7358
  struct CreateTypeInfo;
7359
+ struct CreateTableInfo;
7391
7360
 
7392
7361
  class ClientContext;
7393
7362
  class Transaction;
@@ -7410,7 +7379,7 @@ struct CatalogEntryLookup {
7410
7379
  SchemaCatalogEntry *schema;
7411
7380
  CatalogEntry *entry;
7412
7381
 
7413
- bool Found() const {
7382
+ DUCKDB_API bool Found() const {
7414
7383
  return entry;
7415
7384
  }
7416
7385
  };
@@ -7424,11 +7393,11 @@ struct SimilarCatalogEntry {
7424
7393
  //! The schema of the entry.
7425
7394
  SchemaCatalogEntry *schema;
7426
7395
 
7427
- bool Found() const {
7396
+ DUCKDB_API bool Found() const {
7428
7397
  return !name.empty();
7429
7398
  }
7430
7399
 
7431
- string GetQualifiedName() const;
7400
+ DUCKDB_API string GetQualifiedName() const;
7432
7401
  };
7433
7402
 
7434
7403
  //! The Catalog object represents the catalog of the database.
@@ -7448,79 +7417,93 @@ public:
7448
7417
 
7449
7418
  public:
7450
7419
  //! Get the ClientContext from the Catalog
7451
- static Catalog &GetCatalog(ClientContext &context);
7452
- static Catalog &GetCatalog(DatabaseInstance &db);
7420
+ DUCKDB_API static Catalog &GetCatalog(ClientContext &context);
7421
+ DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db);
7453
7422
 
7454
- DependencyManager &GetDependencyManager() {
7423
+ DUCKDB_API DependencyManager &GetDependencyManager() {
7455
7424
  return *dependency_manager;
7456
7425
  }
7457
7426
 
7458
7427
  //! Returns the current version of the catalog (incremented whenever anything changes, not stored between restarts)
7459
- idx_t GetCatalogVersion();
7428
+ DUCKDB_API idx_t GetCatalogVersion();
7460
7429
  //! Trigger a modification in the catalog, increasing the catalog version and returning the previous version
7461
- idx_t ModifyCatalog();
7430
+ DUCKDB_API idx_t ModifyCatalog();
7462
7431
 
7463
7432
  //! Creates a schema in the catalog.
7464
- CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
7433
+ DUCKDB_API CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
7465
7434
  //! Creates a table in the catalog.
7466
- CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
7435
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
7436
+ //! Creates a table in the catalog.
7437
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, unique_ptr<CreateTableInfo> info);
7467
7438
  //! Create a table function in the catalog
7468
- CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
7439
+ DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
7469
7440
  //! Create a copy function in the catalog
7470
- CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
7441
+ DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
7471
7442
  //! Create a pragma function in the catalog
7472
- CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
7443
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
7473
7444
  //! Create a scalar or aggregate function in the catalog
7474
- CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
7445
+ DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
7475
7446
  //! Creates a table in the catalog.
7476
- CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
7447
+ DUCKDB_API CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
7477
7448
  //! Creates a table in the catalog.
7478
- CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
7449
+ DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
7479
7450
  //! Creates a Enum in the catalog.
7480
- CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
7451
+ DUCKDB_API CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
7481
7452
  //! Creates a collation in the catalog
7482
- CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
7453
+ DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
7483
7454
 
7484
7455
  //! Creates a table in the catalog.
7485
- CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema, BoundCreateTableInfo *info);
7456
+ DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema,
7457
+ BoundCreateTableInfo *info);
7486
7458
  //! Create a table function in the catalog
7487
- CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
7488
- CreateTableFunctionInfo *info);
7459
+ DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
7460
+ CreateTableFunctionInfo *info);
7489
7461
  //! Create a copy function in the catalog
7490
- CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateCopyFunctionInfo *info);
7462
+ DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema,
7463
+ CreateCopyFunctionInfo *info);
7491
7464
  //! Create a pragma function in the catalog
7492
- CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
7493
- CreatePragmaFunctionInfo *info);
7465
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
7466
+ CreatePragmaFunctionInfo *info);
7494
7467
  //! Create a scalar or aggregate function in the catalog
7495
- CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info);
7468
+ DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema,
7469
+ CreateFunctionInfo *info);
7496
7470
  //! Creates a table in the catalog.
7497
- CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
7471
+ DUCKDB_API CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
7498
7472
  //! Creates a table in the catalog.
7499
- CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema, CreateSequenceInfo *info);
7473
+ DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema,
7474
+ CreateSequenceInfo *info);
7500
7475
  //! Creates a enum in the catalog.
7501
- CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
7476
+ DUCKDB_API CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
7502
7477
  //! Creates a collation in the catalog
7503
- CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema, CreateCollationInfo *info);
7478
+ DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema,
7479
+ CreateCollationInfo *info);
7504
7480
 
7505
7481
  //! Drops an entry from the catalog
7506
- void DropEntry(ClientContext &context, DropInfo *info);
7482
+ DUCKDB_API void DropEntry(ClientContext &context, DropInfo *info);
7507
7483
 
7508
7484
  //! Returns the schema object with the specified name, or throws an exception if it does not exist
7509
- SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA, bool if_exists = false,
7510
- QueryErrorContext error_context = QueryErrorContext());
7485
+ DUCKDB_API SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA,
7486
+ bool if_exists = false,
7487
+ QueryErrorContext error_context = QueryErrorContext());
7511
7488
  //! Scans all the schemas in the system one-by-one, invoking the callback for each entry
7512
- void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
7489
+ DUCKDB_API void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
7513
7490
  //! Gets the "schema.name" entry of the specified type, if if_exists=true returns nullptr if entry does not exist,
7514
7491
  //! otherwise an exception is thrown
7515
- CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema, const string &name,
7516
- bool if_exists = false, QueryErrorContext error_context = QueryErrorContext());
7492
+ DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema,
7493
+ const string &name, bool if_exists = false,
7494
+ QueryErrorContext error_context = QueryErrorContext());
7517
7495
 
7518
7496
  template <class T>
7519
7497
  T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
7520
7498
  QueryErrorContext error_context = QueryErrorContext());
7521
7499
 
7500
+ //! Append a scalar or aggregate function to the catalog
7501
+ DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
7502
+ //! Append a scalar or aggregate function to the catalog
7503
+ DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info);
7504
+
7522
7505
  //! Alter an existing entry in the catalog.
7523
- void Alter(ClientContext &context, AlterInfo *info);
7506
+ DUCKDB_API void Alter(ClientContext &context, AlterInfo *info);
7524
7507
 
7525
7508
  private:
7526
7509
  //! The catalog version, incremented whenever anything changes in the catalog
@@ -7544,26 +7527,30 @@ private:
7544
7527
  };
7545
7528
 
7546
7529
  template <>
7547
- TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7548
- bool if_exists, QueryErrorContext error_context);
7530
+ DUCKDB_API TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7531
+ bool if_exists, QueryErrorContext error_context);
7549
7532
  template <>
7550
- SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7551
- bool if_exists, QueryErrorContext error_context);
7533
+ DUCKDB_API SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7534
+ const string &name, bool if_exists, QueryErrorContext error_context);
7552
7535
  template <>
7553
- TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7554
- bool if_exists, QueryErrorContext error_context);
7536
+ DUCKDB_API TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7537
+ const string &name, bool if_exists,
7538
+ QueryErrorContext error_context);
7555
7539
  template <>
7556
- CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7557
- bool if_exists, QueryErrorContext error_context);
7540
+ DUCKDB_API CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7541
+ const string &name, bool if_exists,
7542
+ QueryErrorContext error_context);
7558
7543
  template <>
7559
- PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7560
- bool if_exists, QueryErrorContext error_context);
7544
+ DUCKDB_API PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7545
+ const string &name, bool if_exists,
7546
+ QueryErrorContext error_context);
7561
7547
  template <>
7562
- AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7563
- bool if_exists, QueryErrorContext error_context);
7548
+ DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
7549
+ const string &name, bool if_exists,
7550
+ QueryErrorContext error_context);
7564
7551
  template <>
7565
- CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7566
- bool if_exists, QueryErrorContext error_context);
7552
+ DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
7553
+ bool if_exists, QueryErrorContext error_context);
7567
7554
 
7568
7555
  } // namespace duckdb
7569
7556
 
@@ -7598,6 +7585,7 @@ enum class LogicalOperatorType : uint8_t {
7598
7585
  LOGICAL_COPY_TO_FILE = 10,
7599
7586
  LOGICAL_DISTINCT = 11,
7600
7587
  LOGICAL_SAMPLE = 12,
7588
+ LOGICAL_LIMIT_PERCENT = 13,
7601
7589
 
7602
7590
  // -----------------------------
7603
7591
  // Data sources
@@ -7928,7 +7916,7 @@ struct ColumnBinding {
7928
7916
  idx_t table_index;
7929
7917
  idx_t column_index;
7930
7918
 
7931
- ColumnBinding() : table_index(INVALID_INDEX), column_index(INVALID_INDEX) {
7919
+ ColumnBinding() : table_index(DConstants::INVALID_INDEX), column_index(DConstants::INVALID_INDEX) {
7932
7920
  }
7933
7921
  ColumnBinding(idx_t table, idx_t column) : table_index(table), column_index(column) {
7934
7922
  }
@@ -7982,7 +7970,7 @@ public:
7982
7970
 
7983
7971
  virtual string GetName() const;
7984
7972
  virtual string ParamsToString() const;
7985
- virtual string ToString(idx_t depth = 0) const;
7973
+ virtual string ToString() const;
7986
7974
  void Print();
7987
7975
  //! Debug method: verify that the integrity of expressions & child nodes are maintained
7988
7976
  virtual void Verify();
@@ -8089,6 +8077,20 @@ public:
8089
8077
  vector<unique_ptr<Expression>> target_distincts;
8090
8078
  };
8091
8079
 
8080
+ class BoundLimitPercentModifier : public BoundResultModifier {
8081
+ public:
8082
+ BoundLimitPercentModifier() : BoundResultModifier(ResultModifierType::LIMIT_PERCENT_MODIFIER) {
8083
+ }
8084
+ //! LIMIT %
8085
+ double limit_percent = 100.0;
8086
+ //! OFFSET
8087
+ int64_t offset_val = 0;
8088
+ //! Expression in case limit is not constant
8089
+ unique_ptr<Expression> limit;
8090
+ //! Expression in case limit is not constant
8091
+ unique_ptr<Expression> offset;
8092
+ };
8093
+
8092
8094
  } // namespace duckdb
8093
8095
 
8094
8096
 
@@ -8126,26 +8128,29 @@ typedef void (*aggregate_simple_update_t)(Vector inputs[], FunctionData *bind_da
8126
8128
  //! The type used for updating complex windowed aggregate functions (optional)
8127
8129
  typedef std::pair<idx_t, idx_t> FrameBounds;
8128
8130
  typedef void (*aggregate_window_t)(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
8129
- const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t offset);
8131
+ const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid,
8132
+ idx_t bias);
8130
8133
 
8131
8134
  class AggregateFunction : public BaseScalarFunction {
8132
8135
  public:
8133
- AggregateFunction(const string &name, const vector<LogicalType> &arguments, const LogicalType &return_type,
8134
- aggregate_size_t state_size, aggregate_initialize_t initialize, aggregate_update_t update,
8135
- aggregate_combine_t combine, aggregate_finalize_t finalize,
8136
- aggregate_simple_update_t simple_update = nullptr, bind_aggregate_function_t bind = nullptr,
8137
- aggregate_destructor_t destructor = nullptr, aggregate_statistics_t statistics = nullptr,
8138
- aggregate_window_t window = nullptr)
8136
+ DUCKDB_API AggregateFunction(const string &name, const vector<LogicalType> &arguments,
8137
+ const LogicalType &return_type, aggregate_size_t state_size,
8138
+ aggregate_initialize_t initialize, aggregate_update_t update,
8139
+ 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)
8139
8143
  : BaseScalarFunction(name, arguments, return_type, false), state_size(state_size), initialize(initialize),
8140
8144
  update(update), combine(combine), finalize(finalize), simple_update(simple_update), window(window),
8141
8145
  bind(bind), destructor(destructor), statistics(statistics) {
8142
8146
  }
8143
8147
 
8144
- AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type, aggregate_size_t state_size,
8145
- aggregate_initialize_t initialize, aggregate_update_t update, aggregate_combine_t combine,
8146
- aggregate_finalize_t finalize, aggregate_simple_update_t simple_update = nullptr,
8147
- bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8148
- aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8148
+ DUCKDB_API AggregateFunction(const vector<LogicalType> &arguments, const LogicalType &return_type,
8149
+ aggregate_size_t state_size, aggregate_initialize_t initialize,
8150
+ aggregate_update_t update, aggregate_combine_t combine, aggregate_finalize_t finalize,
8151
+ aggregate_simple_update_t simple_update = nullptr,
8152
+ bind_aggregate_function_t bind = nullptr, aggregate_destructor_t destructor = nullptr,
8153
+ aggregate_statistics_t statistics = nullptr, aggregate_window_t window = nullptr)
8149
8154
  : AggregateFunction(string(), arguments, return_type, state_size, initialize, update, combine, finalize,
8150
8155
  simple_update, bind, destructor, statistics, window) {
8151
8156
  }
@@ -8173,23 +8178,23 @@ public:
8173
8178
  //! The statistics propagation function (may be null)
8174
8179
  aggregate_statistics_t statistics;
8175
8180
 
8176
- bool operator==(const AggregateFunction &rhs) const {
8181
+ DUCKDB_API bool operator==(const AggregateFunction &rhs) const {
8177
8182
  return state_size == rhs.state_size && initialize == rhs.initialize && update == rhs.update &&
8178
8183
  combine == rhs.combine && finalize == rhs.finalize && window == rhs.window;
8179
8184
  }
8180
- bool operator!=(const AggregateFunction &rhs) const {
8185
+ DUCKDB_API bool operator!=(const AggregateFunction &rhs) const {
8181
8186
  return !(*this == rhs);
8182
8187
  }
8183
8188
 
8184
- static unique_ptr<BoundAggregateExpression>
8189
+ DUCKDB_API static unique_ptr<BoundAggregateExpression>
8185
8190
  BindAggregateFunction(ClientContext &context, AggregateFunction bound_function,
8186
8191
  vector<unique_ptr<Expression>> children, unique_ptr<Expression> filter = nullptr,
8187
8192
  bool is_distinct = false, unique_ptr<BoundOrderModifier> order_bys = nullptr);
8188
8193
 
8189
- static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
8190
- vector<unique_ptr<Expression>> &children,
8191
- unique_ptr<FunctionData> bind_info,
8192
- unique_ptr<BoundOrderModifier> order_bys);
8194
+ DUCKDB_API static unique_ptr<FunctionData> BindSortedAggregate(AggregateFunction &bound_function,
8195
+ vector<unique_ptr<Expression>> &children,
8196
+ unique_ptr<FunctionData> bind_info,
8197
+ unique_ptr<BoundOrderModifier> order_bys);
8193
8198
 
8194
8199
  public:
8195
8200
  template <class STATE, class RESULT_TYPE, class OP>
@@ -8268,10 +8273,10 @@ public:
8268
8273
 
8269
8274
  template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
8270
8275
  static void UnaryWindow(Vector inputs[], FunctionData *bind_data, idx_t input_count, data_ptr_t state,
8271
- const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid) {
8276
+ const FrameBounds &frame, const FrameBounds &prev, Vector &result, idx_t rid, idx_t bias) {
8272
8277
  D_ASSERT(input_count == 1);
8273
8278
  AggregateExecutor::UnaryWindow<STATE, INPUT_TYPE, RESULT_TYPE, OP>(inputs[0], bind_data, state, frame, prev,
8274
- result, rid);
8279
+ result, rid, bias);
8275
8280
  }
8276
8281
 
8277
8282
  template <class STATE, class A_TYPE, class B_TYPE, class OP>
@@ -8592,7 +8597,7 @@ private:
8592
8597
  }
8593
8598
 
8594
8599
  template <typename T>
8595
- static bool TypesMatch(LogicalType sql_type) {
8600
+ static bool TypesMatch(const LogicalType &sql_type) {
8596
8601
  switch (sql_type.id()) {
8597
8602
  case LogicalTypeId::BOOLEAN:
8598
8603
  return std::is_same<T, bool>();
@@ -8605,13 +8610,16 @@ private:
8605
8610
  case LogicalTypeId::BIGINT:
8606
8611
  return std::is_same<T, int64_t>();
8607
8612
  case LogicalTypeId::DATE:
8613
+ case LogicalTypeId::DATE_TZ:
8608
8614
  return std::is_same<T, date_t>();
8609
8615
  case LogicalTypeId::TIME:
8616
+ case LogicalTypeId::TIME_TZ:
8610
8617
  return std::is_same<T, dtime_t>();
8611
8618
  case LogicalTypeId::TIMESTAMP:
8612
8619
  case LogicalTypeId::TIMESTAMP_MS:
8613
8620
  case LogicalTypeId::TIMESTAMP_NS:
8614
8621
  case LogicalTypeId::TIMESTAMP_SEC:
8622
+ case LogicalTypeId::TIMESTAMP_TZ:
8615
8623
  return std::is_same<T, timestamp_t>();
8616
8624
  case LogicalTypeId::FLOAT:
8617
8625
  return std::is_same<T, float>();
@@ -9464,11 +9472,13 @@ namespace duckdb {
9464
9472
  class Printer {
9465
9473
  public:
9466
9474
  //! Print the object to stderr
9467
- static void Print(const string &str);
9475
+ DUCKDB_API static void Print(const string &str);
9468
9476
  //! Prints Progress
9469
- static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9477
+ DUCKDB_API static void PrintProgress(int percentage, const char *pbstr, int pbwidth);
9470
9478
  //! Prints an empty line when progress bar is done
9471
- static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9479
+ DUCKDB_API static void FinishProgressBarPrint(const char *pbstr, int pbwidth);
9480
+ //! Whether or not we are printing to a terminal
9481
+ DUCKDB_API static bool IsTerminal();
9472
9482
  };
9473
9483
  } // namespace duckdb
9474
9484
 
@@ -9830,16 +9840,16 @@ namespace duckdb {
9830
9840
  */
9831
9841
  class StringUtil {
9832
9842
  public:
9833
- static bool CharacterIsSpace(char c) {
9843
+ DUCKDB_API static bool CharacterIsSpace(char c) {
9834
9844
  return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r';
9835
9845
  }
9836
- static bool CharacterIsNewline(char c) {
9846
+ DUCKDB_API static bool CharacterIsNewline(char c) {
9837
9847
  return c == '\n' || c == '\r';
9838
9848
  }
9839
- static bool CharacterIsDigit(char c) {
9849
+ DUCKDB_API static bool CharacterIsDigit(char c) {
9840
9850
  return c >= '0' && c <= '9';
9841
9851
  }
9842
- static char CharacterToLower(char c) {
9852
+ DUCKDB_API static char CharacterToLower(char c) {
9843
9853
  if (c >= 'A' && c <= 'Z') {
9844
9854
  return c - ('A' - 'a');
9845
9855
  }
@@ -9847,25 +9857,25 @@ public:
9847
9857
  }
9848
9858
 
9849
9859
  //! Returns true if the needle string exists in the haystack
9850
- static bool Contains(const string &haystack, const string &needle);
9860
+ DUCKDB_API static bool Contains(const string &haystack, const string &needle);
9851
9861
 
9852
9862
  //! Returns true if the target string starts with the given prefix
9853
- static bool StartsWith(string str, string prefix);
9863
+ DUCKDB_API static bool StartsWith(string str, string prefix);
9854
9864
 
9855
9865
  //! Returns true if the target string <b>ends</b> with the given suffix.
9856
- static bool EndsWith(const string &str, const string &suffix);
9866
+ DUCKDB_API static bool EndsWith(const string &str, const string &suffix);
9857
9867
 
9858
9868
  //! Repeat a string multiple times
9859
- static string Repeat(const string &str, const idx_t n);
9869
+ DUCKDB_API static string Repeat(const string &str, const idx_t n);
9860
9870
 
9861
9871
  //! Split the input string based on newline char
9862
- static vector<string> Split(const string &str, char delimiter);
9872
+ DUCKDB_API static vector<string> Split(const string &str, char delimiter);
9863
9873
 
9864
9874
  //! Split the input string allong a quote. Note that any escaping is NOT supported.
9865
- static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
9875
+ DUCKDB_API static vector<string> SplitWithQuote(const string &str, char delimiter = ',', char quote = '"');
9866
9876
 
9867
9877
  //! Join multiple strings into one string. Components are concatenated by the given separator
9868
- static string Join(const vector<string> &input, const string &separator);
9878
+ DUCKDB_API static string Join(const vector<string> &input, const string &separator);
9869
9879
 
9870
9880
  //! Join multiple items of container with given size, transformed to string
9871
9881
  //! using function, into one string using the given separator
@@ -9889,13 +9899,13 @@ public:
9889
9899
  }
9890
9900
 
9891
9901
  //! Return a string that formats the give number of bytes
9892
- static string BytesToHumanReadableString(idx_t bytes);
9902
+ DUCKDB_API static string BytesToHumanReadableString(idx_t bytes);
9893
9903
 
9894
9904
  //! Convert a string to uppercase
9895
- static string Upper(const string &str);
9905
+ DUCKDB_API static string Upper(const string &str);
9896
9906
 
9897
9907
  //! Convert a string to lowercase
9898
- static string Lower(const string &str);
9908
+ DUCKDB_API static string Lower(const string &str);
9899
9909
 
9900
9910
  //! Format a string using printf semantics
9901
9911
  template <typename... Args>
@@ -9904,30 +9914,38 @@ public:
9904
9914
  }
9905
9915
 
9906
9916
  //! Split the input string into a vector of strings based on the split string
9907
- static vector<string> Split(const string &input, const string &split);
9917
+ DUCKDB_API static vector<string> Split(const string &input, const string &split);
9908
9918
 
9909
9919
  //! Remove the whitespace char in the left end of the string
9910
- static void LTrim(string &str);
9920
+ DUCKDB_API static void LTrim(string &str);
9911
9921
  //! Remove the whitespace char in the right end of the string
9912
- static void RTrim(string &str);
9922
+ DUCKDB_API static void RTrim(string &str);
9913
9923
  //! Remove the whitespace char in the left and right end of the string
9914
- static void Trim(string &str);
9924
+ DUCKDB_API static void Trim(string &str);
9915
9925
 
9916
- static string Replace(string source, const string &from, const string &to);
9926
+ DUCKDB_API static string Replace(string source, const string &from, const string &to);
9917
9927
 
9918
9928
  //! Get the levenshtein distance from two strings
9919
- static idx_t LevenshteinDistance(const string &s1, const string &s2);
9929
+ DUCKDB_API static idx_t LevenshteinDistance(const string &s1, const string &s2);
9920
9930
 
9921
9931
  //! Get the top-n strings (sorted by the given score distance) from a set of scores.
9922
9932
  //! At least one entry is returned (if there is one).
9923
9933
  //! Strings are only returned if they have a score less than the threshold.
9924
- static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5, idx_t threshold = 5);
9934
+ DUCKDB_API static vector<string> TopNStrings(vector<std::pair<string, idx_t>> scores, idx_t n = 5,
9935
+ idx_t threshold = 5);
9925
9936
  //! Computes the levenshtein distance of each string in strings, and compares it to target, then returns TopNStrings
9926
9937
  //! with the given params.
9927
- static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
9928
- idx_t threshold = 5);
9929
- static string CandidatesMessage(const vector<string> &candidates, const string &candidate = "Candidate bindings");
9938
+ DUCKDB_API static vector<string> TopNLevenshtein(const vector<string> &strings, const string &target, idx_t n = 5,
9939
+ idx_t threshold = 5);
9940
+ DUCKDB_API static string CandidatesMessage(const vector<string> &candidates,
9941
+ const string &candidate = "Candidate bindings");
9942
+
9943
+ //! Generate an error message in the form of "{message_prefix}: nearest_string, nearest_string2, ...
9944
+ //! Equivalent to calling TopNLevenshtein followed by CandidatesMessage
9945
+ DUCKDB_API static string CandidatesErrorMessage(const vector<string> &strings, const string &target,
9946
+ const string &message_prefix, idx_t n = 5);
9930
9947
  };
9948
+
9931
9949
  } // namespace duckdb
9932
9950
 
9933
9951
 
@@ -10040,6 +10058,7 @@ enum class OptimizerType : uint32_t {
10040
10058
  };
10041
10059
 
10042
10060
  string OptimizerTypeToString(OptimizerType type);
10061
+ OptimizerType OptimizerTypeFromString(const string &str);
10043
10062
 
10044
10063
  } // namespace duckdb
10045
10064
 
@@ -10068,6 +10087,29 @@ enum class WindowAggregationMode : uint32_t {
10068
10087
 
10069
10088
  } // namespace duckdb
10070
10089
 
10090
+ //===----------------------------------------------------------------------===//
10091
+ // DuckDB
10092
+ //
10093
+ // duckdb/common/enums/set_scope.hpp
10094
+ //
10095
+ //
10096
+ //===----------------------------------------------------------------------===//
10097
+
10098
+
10099
+
10100
+
10101
+
10102
+ namespace duckdb {
10103
+
10104
+ enum class SetScope : uint8_t {
10105
+ AUTOMATIC = 0,
10106
+ LOCAL = 1, /* unused */
10107
+ SESSION = 2,
10108
+ GLOBAL = 3
10109
+ };
10110
+
10111
+ } // namespace duckdb
10112
+
10071
10113
 
10072
10114
  namespace duckdb {
10073
10115
  class ClientContext;
@@ -10075,6 +10117,7 @@ class TableFunctionRef;
10075
10117
  class CompressionFunction;
10076
10118
 
10077
10119
  struct CompressionFunctionSet;
10120
+ struct DBConfig;
10078
10121
 
10079
10122
  enum class AccessMode : uint8_t { UNDEFINED = 0, AUTOMATIC = 1, READ_ONLY = 2, READ_WRITE = 3 };
10080
10123
 
@@ -10085,25 +10128,31 @@ enum class CheckpointAbort : uint8_t {
10085
10128
  DEBUG_ABORT_AFTER_FREE_LIST_WRITE = 3
10086
10129
  };
10087
10130
 
10088
- enum class ConfigurationOptionType : uint32_t {
10089
- INVALID = 0,
10090
- ACCESS_MODE,
10091
- DEFAULT_ORDER_TYPE,
10092
- DEFAULT_NULL_ORDER,
10093
- ENABLE_EXTERNAL_ACCESS,
10094
- ENABLE_OBJECT_CACHE,
10095
- MAXIMUM_MEMORY,
10096
- THREADS
10097
- };
10131
+ typedef void (*set_global_function_t)(DatabaseInstance *db, DBConfig &config, const Value &parameter);
10132
+ typedef void (*set_local_function_t)(ClientContext &context, const Value &parameter);
10133
+ typedef Value (*get_setting_function_t)(ClientContext &context);
10098
10134
 
10099
10135
  struct ConfigurationOption {
10100
- ConfigurationOptionType type;
10101
10136
  const char *name;
10102
10137
  const char *description;
10103
10138
  LogicalTypeId parameter_type;
10139
+ set_global_function_t set_global;
10140
+ set_local_function_t set_local;
10141
+ get_setting_function_t get_setting;
10142
+ };
10143
+
10144
+ typedef void (*set_option_callback_t)(ClientContext &context, SetScope scope, Value &parameter);
10145
+
10146
+ struct ExtensionOption {
10147
+ ExtensionOption(string description_p, LogicalType type_p, set_option_callback_t set_function_p)
10148
+ : description(move(description_p)), type(move(type_p)), set_function(set_function_p) {
10149
+ }
10150
+
10151
+ string description;
10152
+ LogicalType type;
10153
+ set_option_callback_t set_function;
10104
10154
  };
10105
10155
 
10106
- // this is optional and only used in tests at the moment
10107
10156
  struct DBConfig {
10108
10157
  friend class DatabaseInstance;
10109
10158
  friend class StorageManager;
@@ -10143,8 +10192,6 @@ public:
10143
10192
  bool enable_external_access = true;
10144
10193
  //! Whether or not object cache is used
10145
10194
  bool object_cache_enable = false;
10146
- //! Database configuration variables as controlled by SET
10147
- case_insensitive_map_t<Value> set_variables;
10148
10195
  //! Force checkpoint when CHECKPOINT is called or on shutdown, even if no changes have been made
10149
10196
  bool force_checkpoint = false;
10150
10197
  //! Run a checkpoint on successful shutdown and delete the WAL, to leave only a single database file behind
@@ -10165,6 +10212,14 @@ public:
10165
10212
  //! Debug setting for window aggregation mode: (window, combine, separate)
10166
10213
  WindowAggregationMode window_mode = WindowAggregationMode::WINDOW;
10167
10214
 
10215
+ //! Extra parameters that can be SET for loaded extensions
10216
+ case_insensitive_map_t<ExtensionOption> extension_parameters;
10217
+ //! Database configuration variables as controlled by SET
10218
+ case_insensitive_map_t<Value> set_variables;
10219
+
10220
+ DUCKDB_API void AddExtensionOption(string name, string description, LogicalType parameter,
10221
+ set_option_callback_t function = nullptr);
10222
+
10168
10223
  public:
10169
10224
  DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
10170
10225
  DUCKDB_API static DBConfig &GetConfig(DatabaseInstance &db);
@@ -10210,8 +10265,10 @@ class DuckDB;
10210
10265
  //! The Extension class is the base class used to define extensions
10211
10266
  class Extension {
10212
10267
  public:
10268
+ DUCKDB_API virtual ~Extension();
10269
+
10213
10270
  DUCKDB_API virtual void Load(DuckDB &db) = 0;
10214
- DUCKDB_API virtual ~Extension() = default;
10271
+ DUCKDB_API virtual std::string Name() = 0;
10215
10272
  };
10216
10273
 
10217
10274
  } // namespace duckdb
@@ -10259,6 +10316,7 @@ private:
10259
10316
  unique_ptr<TaskScheduler> scheduler;
10260
10317
  unique_ptr<ObjectCache> object_cache;
10261
10318
  unique_ptr<ConnectionManager> connection_manager;
10319
+ unordered_set<std::string> loaded_extensions;
10262
10320
  };
10263
10321
 
10264
10322
  //! The database object. This object holds the catalog and all the
@@ -10267,6 +10325,8 @@ class DuckDB {
10267
10325
  public:
10268
10326
  DUCKDB_API explicit DuckDB(const char *path = nullptr, DBConfig *config = nullptr);
10269
10327
  DUCKDB_API explicit DuckDB(const string &path, DBConfig *config = nullptr);
10328
+ DUCKDB_API explicit DuckDB(DatabaseInstance &instance);
10329
+
10270
10330
  DUCKDB_API ~DuckDB();
10271
10331
 
10272
10332
  //! Reference to the actual database instance
@@ -10276,7 +10336,11 @@ public:
10276
10336
  template <class T>
10277
10337
  void LoadExtension() {
10278
10338
  T extension;
10339
+ if (ExtensionIsLoaded(extension.Name())) {
10340
+ return;
10341
+ }
10279
10342
  extension.Load(*this);
10343
+ SetExtensionLoaded(extension.Name());
10280
10344
  }
10281
10345
 
10282
10346
  DUCKDB_API FileSystem &GetFileSystem();
@@ -10284,16 +10348,39 @@ public:
10284
10348
  DUCKDB_API idx_t NumberOfThreads();
10285
10349
  DUCKDB_API static const char *SourceID();
10286
10350
  DUCKDB_API static const char *LibraryVersion();
10351
+ DUCKDB_API static string Platform();
10352
+ DUCKDB_API bool ExtensionIsLoaded(const std::string &name);
10353
+ DUCKDB_API void SetExtensionLoaded(const std::string &name);
10287
10354
  };
10288
10355
 
10289
10356
  } // namespace duckdb
10290
10357
 
10291
10358
 
10359
+ //===----------------------------------------------------------------------===//
10360
+ // DuckDB
10361
+ //
10362
+ // duckdb/main/loadable_extension.hpp
10363
+ //
10364
+ //
10365
+ //===----------------------------------------------------------------------===//
10366
+
10292
10367
 
10293
10368
 
10294
10369
  #ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
10295
10370
  #ifdef _WIN32
10371
+ #ifndef NOMINMAX
10372
+ #define NOMINMAX
10373
+ #endif
10374
+
10375
+ #ifndef _WINSOCKAPI_
10376
+ #define _WINSOCKAPI_
10377
+ #endif
10296
10378
  #include <windows.h>
10379
+
10380
+ #undef CreateDirectory
10381
+ #undef MoveFile
10382
+ #undef RemoveDirectory
10383
+
10297
10384
  #include <delayimp.h>
10298
10385
 
10299
10386
  extern "C" {
@@ -10301,7 +10388,7 @@ extern "C" {
10301
10388
  This is interesting: Windows would normally require a duckdb.dll being on the DLL search path when we load an extension
10302
10389
  using LoadLibrary(). However, there is likely no such dll, because DuckDB was statically linked, or is running as part
10303
10390
  of an R or Python module with a completely different name (that we don't know) or something of the sorts. Amazingly,
10304
- Windows supports lazy-loading DLLs by linking them with /DELAYLOAD. Then a callback will be triggerd whenever we access
10391
+ Windows supports lazy-loading DLLs by linking them with /DELAYLOAD. Then a callback will be triggered whenever we access
10305
10392
  symbols in the extension. Since DuckDB is already running in the host process (hopefully), we can use
10306
10393
  GetModuleHandle(NULL) to return the current process so the symbols are looked for there. See here for another
10307
10394
  explanation of this crazy process:
@@ -10339,8 +10426,9 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
10339
10426
 
10340
10427
 
10341
10428
 
10429
+ #ifndef DUCKDB_API
10342
10430
  #ifdef _WIN32
10343
- #ifdef DUCKDB_BUILD_LIBRARY
10431
+ #if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
10344
10432
  #define DUCKDB_API __declspec(dllexport)
10345
10433
  #else
10346
10434
  #define DUCKDB_API __declspec(dllimport)
@@ -10348,6 +10436,7 @@ ExternC const PfnDliHook __pfnDliFailureHook2 = duckdb_dllimport_delay_hook;
10348
10436
  #else
10349
10437
  #define DUCKDB_API
10350
10438
  #endif
10439
+ #endif
10351
10440
 
10352
10441
  #include <stdbool.h>
10353
10442
  #include <stdint.h>
@@ -11742,6 +11831,12 @@ struct timestamp_struct {
11742
11831
  //! The Timestamp class is a static class that holds helper functions for the Timestamp
11743
11832
  //! type.
11744
11833
  class Timestamp {
11834
+ public:
11835
+ // min timestamp is 290308-12-22 (BC)
11836
+ constexpr static const int32_t MIN_YEAR = -290308;
11837
+ constexpr static const int32_t MIN_MONTH = 12;
11838
+ constexpr static const int32_t MIN_DAY = 22;
11839
+
11745
11840
  public:
11746
11841
  //! Convert a string in the format "YYYY-MM-DD hh:mm:ss" to a timestamp object
11747
11842
  DUCKDB_API static timestamp_t FromString(const string &str);
@@ -11814,6 +11909,8 @@ public:
11814
11909
 
11815
11910
  //! Convert a time object to a string in the format "hh:mm:ss"
11816
11911
  DUCKDB_API static string ToString(dtime_t time);
11912
+ //! Convert a UTC offset to ±HH[:MM]
11913
+ DUCKDB_API static string ToUTCOffset(int hour_offset, int minute_offset);
11817
11914
 
11818
11915
  DUCKDB_API static dtime_t FromTime(int32_t hour, int32_t minute, int32_t second, int32_t microseconds = 0);
11819
11916
 
@@ -11901,14 +11998,11 @@ class TableCatalogEntry;
11901
11998
  class Connection;
11902
11999
 
11903
12000
  //! The Appender class can be used to append elements to a table.
11904
- class Appender {
12001
+ class BaseAppender {
12002
+ protected:
11905
12003
  //! The amount of chunks that will be gathered in the chunk collection before flushing
11906
12004
  static constexpr const idx_t FLUSH_COUNT = 100;
11907
12005
 
11908
- //! A reference to a database connection that created this appender
11909
- shared_ptr<ClientContext> context;
11910
- //! The table description (including column names)
11911
- unique_ptr<TableDescription> description;
11912
12006
  //! The append types
11913
12007
  vector<LogicalType> types;
11914
12008
  //! The buffered data for the append
@@ -11919,9 +12013,9 @@ class Appender {
11919
12013
  idx_t column = 0;
11920
12014
 
11921
12015
  public:
11922
- DUCKDB_API Appender(Connection &con, const string &schema_name, const string &table_name);
11923
- DUCKDB_API Appender(Connection &con, const string &table_name);
11924
- DUCKDB_API ~Appender();
12016
+ DUCKDB_API BaseAppender();
12017
+ DUCKDB_API BaseAppender(vector<LogicalType> types);
12018
+ DUCKDB_API virtual ~BaseAppender();
11925
12019
 
11926
12020
  //! Begins a new row append, after calling this the other AppendX() functions
11927
12021
  //! should be called the correct amount of times. After that,
@@ -11957,7 +12051,9 @@ public:
11957
12051
  return column;
11958
12052
  }
11959
12053
 
11960
- private:
12054
+ protected:
12055
+ void Destructor();
12056
+ virtual void FlushInternal(ChunkCollection &collection) = 0;
11961
12057
  void InitializeChunk();
11962
12058
  void FlushChunk();
11963
12059
 
@@ -11979,46 +12075,75 @@ private:
11979
12075
  void AppendValue(const Value &value);
11980
12076
  };
11981
12077
 
12078
+ class Appender : public BaseAppender {
12079
+ //! A reference to a database connection that created this appender
12080
+ shared_ptr<ClientContext> context;
12081
+ //! The table description (including column names)
12082
+ unique_ptr<TableDescription> description;
12083
+
12084
+ public:
12085
+ DUCKDB_API Appender(Connection &con, const string &schema_name, const string &table_name);
12086
+ DUCKDB_API Appender(Connection &con, const string &table_name);
12087
+ DUCKDB_API ~Appender() override;
12088
+
12089
+ protected:
12090
+ void FlushInternal(ChunkCollection &collection) override;
12091
+ };
12092
+
12093
+ class InternalAppender : public BaseAppender {
12094
+ //! The client context
12095
+ ClientContext &context;
12096
+ //! The internal table entry to append to
12097
+ TableCatalogEntry &table;
12098
+
12099
+ public:
12100
+ DUCKDB_API InternalAppender(ClientContext &context, TableCatalogEntry &table);
12101
+ DUCKDB_API ~InternalAppender() override;
12102
+
12103
+ protected:
12104
+ void FlushInternal(ChunkCollection &collection) override;
12105
+ };
12106
+
11982
12107
  template <>
11983
- void DUCKDB_API Appender::Append(bool value);
12108
+ DUCKDB_API void BaseAppender::Append(bool value);
11984
12109
  template <>
11985
- void DUCKDB_API Appender::Append(int8_t value);
12110
+ DUCKDB_API void BaseAppender::Append(int8_t value);
11986
12111
  template <>
11987
- void DUCKDB_API Appender::Append(int16_t value);
12112
+ DUCKDB_API void BaseAppender::Append(int16_t value);
11988
12113
  template <>
11989
- void DUCKDB_API Appender::Append(int32_t value);
12114
+ DUCKDB_API void BaseAppender::Append(int32_t value);
11990
12115
  template <>
11991
- void DUCKDB_API Appender::Append(int64_t value);
12116
+ DUCKDB_API void BaseAppender::Append(int64_t value);
11992
12117
  template <>
11993
- void DUCKDB_API Appender::Append(hugeint_t value);
12118
+ DUCKDB_API void BaseAppender::Append(hugeint_t value);
11994
12119
  template <>
11995
- void DUCKDB_API Appender::Append(uint8_t value);
12120
+ DUCKDB_API void BaseAppender::Append(uint8_t value);
11996
12121
  template <>
11997
- void DUCKDB_API Appender::Append(uint16_t value);
12122
+ DUCKDB_API void BaseAppender::Append(uint16_t value);
11998
12123
  template <>
11999
- void DUCKDB_API Appender::Append(uint32_t value);
12124
+ DUCKDB_API void BaseAppender::Append(uint32_t value);
12000
12125
  template <>
12001
- void DUCKDB_API Appender::Append(uint64_t value);
12126
+ DUCKDB_API void BaseAppender::Append(uint64_t value);
12002
12127
  template <>
12003
- void DUCKDB_API Appender::Append(float value);
12128
+ DUCKDB_API void BaseAppender::Append(float value);
12004
12129
  template <>
12005
- void DUCKDB_API Appender::Append(double value);
12130
+ DUCKDB_API void BaseAppender::Append(double value);
12006
12131
  template <>
12007
- void DUCKDB_API Appender::Append(date_t value);
12132
+ DUCKDB_API void BaseAppender::Append(date_t value);
12008
12133
  template <>
12009
- void DUCKDB_API Appender::Append(dtime_t value);
12134
+ DUCKDB_API void BaseAppender::Append(dtime_t value);
12010
12135
  template <>
12011
- void DUCKDB_API Appender::Append(timestamp_t value);
12136
+ DUCKDB_API void BaseAppender::Append(timestamp_t value);
12012
12137
  template <>
12013
- void DUCKDB_API Appender::Append(interval_t value);
12138
+ DUCKDB_API void BaseAppender::Append(interval_t value);
12014
12139
  template <>
12015
- void DUCKDB_API Appender::Append(const char *value);
12140
+ DUCKDB_API void BaseAppender::Append(const char *value);
12016
12141
  template <>
12017
- void DUCKDB_API Appender::Append(string_t value);
12142
+ DUCKDB_API void BaseAppender::Append(string_t value);
12018
12143
  template <>
12019
- void DUCKDB_API Appender::Append(Value value);
12144
+ DUCKDB_API void BaseAppender::Append(Value value);
12020
12145
  template <>
12021
- void DUCKDB_API Appender::Append(std::nullptr_t value);
12146
+ DUCKDB_API void BaseAppender::Append(std::nullptr_t value);
12022
12147
 
12023
12148
  } // namespace duckdb
12024
12149
  //===----------------------------------------------------------------------===//
@@ -12182,22 +12307,21 @@ enum class ConstraintType : uint8_t {
12182
12307
  //! Constraint is the base class of any type of table constraint.
12183
12308
  class Constraint {
12184
12309
  public:
12185
- explicit Constraint(ConstraintType type) : type(type) {};
12186
- virtual ~Constraint() {
12187
- }
12310
+ DUCKDB_API explicit Constraint(ConstraintType type);
12311
+ DUCKDB_API virtual ~Constraint();
12188
12312
 
12189
12313
  ConstraintType type;
12190
12314
 
12191
12315
  public:
12192
- virtual string ToString() const = 0;
12193
- void Print();
12316
+ DUCKDB_API virtual string ToString() const = 0;
12317
+ DUCKDB_API void Print();
12194
12318
 
12195
- virtual unique_ptr<Constraint> Copy() = 0;
12319
+ DUCKDB_API virtual unique_ptr<Constraint> Copy() = 0;
12196
12320
  //! Serializes a Constraint to a stand-alone binary blob
12197
- virtual void Serialize(Serializer &serializer);
12321
+ DUCKDB_API virtual void Serialize(Serializer &serializer);
12198
12322
  //! Deserializes a blob back into a Constraint, returns NULL if
12199
12323
  //! deserialization is not possible
12200
- static unique_ptr<Constraint> Deserialize(Deserializer &source);
12324
+ DUCKDB_API static unique_ptr<Constraint> Deserialize(Deserializer &source);
12201
12325
  };
12202
12326
  } // namespace duckdb
12203
12327
 
@@ -12285,7 +12409,7 @@ public:
12285
12409
 
12286
12410
  //! Returns the column index of the specified column name.
12287
12411
  //! If the column does not exist:
12288
- //! If if_exists is true, returns INVALID_INDEX
12412
+ //! If if_exists is true, returns DConstants::INVALID_INDEX
12289
12413
  //! If if_exists is false, throws an exception
12290
12414
  idx_t GetColumnIndex(string &name, bool if_exists = false);
12291
12415
 
@@ -12324,21 +12448,21 @@ class CatalogSet {
12324
12448
  friend class DependencyManager;
12325
12449
 
12326
12450
  public:
12327
- explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
12451
+ DUCKDB_API explicit CatalogSet(Catalog &catalog, unique_ptr<DefaultGenerator> defaults = nullptr);
12328
12452
 
12329
12453
  //! Create an entry in the catalog set. Returns whether or not it was
12330
12454
  //! successful.
12331
- bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
12332
- unordered_set<CatalogEntry *> &dependencies);
12455
+ DUCKDB_API bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
12456
+ unordered_set<CatalogEntry *> &dependencies);
12333
12457
 
12334
- bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
12458
+ DUCKDB_API bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
12335
12459
 
12336
- bool DropEntry(ClientContext &context, const string &name, bool cascade);
12460
+ DUCKDB_API bool DropEntry(ClientContext &context, const string &name, bool cascade);
12337
12461
 
12338
12462
  void CleanupEntry(CatalogEntry *catalog_entry);
12339
12463
 
12340
12464
  //! Returns the entry with the specified name
12341
- CatalogEntry *GetEntry(ClientContext &context, const string &name);
12465
+ DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &name);
12342
12466
 
12343
12467
  //! Gets the entry that is most similar to the given name (i.e. smallest levenshtein distance), or empty string if
12344
12468
  //! none is found. The returned pair consists of the entry name and the distance (smaller means closer).
@@ -12349,9 +12473,9 @@ public:
12349
12473
  void Undo(CatalogEntry *entry);
12350
12474
 
12351
12475
  //! Scan the catalog set, invoking the callback method for every committed entry
12352
- void Scan(const std::function<void(CatalogEntry *)> &callback);
12476
+ DUCKDB_API void Scan(const std::function<void(CatalogEntry *)> &callback);
12353
12477
  //! Scan the catalog set, invoking the callback method for every entry
12354
- void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
12478
+ DUCKDB_API void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
12355
12479
 
12356
12480
  template <class T>
12357
12481
  vector<T *> GetEntries(ClientContext &context) {
@@ -12360,8 +12484,8 @@ public:
12360
12484
  return result;
12361
12485
  }
12362
12486
 
12363
- static bool HasConflict(ClientContext &context, transaction_t timestamp);
12364
- static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
12487
+ DUCKDB_API static bool HasConflict(ClientContext &context, transaction_t timestamp);
12488
+ DUCKDB_API static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
12365
12489
 
12366
12490
  CatalogEntry *GetEntryFromIndex(idx_t index);
12367
12491
  void UpdateTimestamp(CatalogEntry *entry, transaction_t timestamp);
@@ -12497,6 +12621,9 @@ private:
12497
12621
  //! Drops an entry from the schema
12498
12622
  void DropEntry(ClientContext &context, DropInfo *info);
12499
12623
 
12624
+ //! Append a scalar or aggregate function within the given schema
12625
+ CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
12626
+
12500
12627
  //! Alters a catalog entry
12501
12628
  void Alter(ClientContext &context, AlterInfo *info);
12502
12629
 
@@ -12512,7 +12639,6 @@ private:
12512
12639
  } // namespace duckdb
12513
12640
 
12514
12641
 
12515
-
12516
12642
  //===----------------------------------------------------------------------===//
12517
12643
  // DuckDB
12518
12644
  //
@@ -12528,24 +12654,6 @@ private:
12528
12654
  namespace duckdb {
12529
12655
  using std::deque;
12530
12656
  }
12531
- //===----------------------------------------------------------------------===//
12532
- // DuckDB
12533
- //
12534
- // duckdb/common/enums/output_type.hpp
12535
- //
12536
- //
12537
- //===----------------------------------------------------------------------===//
12538
-
12539
-
12540
-
12541
-
12542
-
12543
- namespace duckdb {
12544
-
12545
- enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
12546
-
12547
- } // namespace duckdb
12548
-
12549
12657
 
12550
12658
  //===----------------------------------------------------------------------===//
12551
12659
  // DuckDB
@@ -12634,6 +12742,7 @@ enum class PhysicalOperatorType : uint8_t {
12634
12742
  INVALID,
12635
12743
  ORDER_BY,
12636
12744
  LIMIT,
12745
+ LIMIT_PERCENT,
12637
12746
  TOP_N,
12638
12747
  WINDOW,
12639
12748
  UNNEST,
@@ -12697,6 +12806,7 @@ enum class PhysicalOperatorType : uint8_t {
12697
12806
  // Helpers
12698
12807
  // -----------------------------
12699
12808
  EXPLAIN,
12809
+ EXPLAIN_ANALYZE,
12700
12810
  EMPTY_RESULT,
12701
12811
  EXECUTE,
12702
12812
  PREPARE,
@@ -12845,7 +12955,7 @@ public:
12845
12955
  vector<unique_ptr<PhysicalOperator>> children;
12846
12956
  //! The types returned by this physical operator
12847
12957
  vector<LogicalType> types;
12848
- //! The extimated cardinality of this physical operator
12958
+ //! The estimated cardinality of this physical operator
12849
12959
  idx_t estimated_cardinality;
12850
12960
  //! The global sink state of this operator
12851
12961
  unique_ptr<GlobalSinkState> sink_state;
@@ -12955,14 +13065,13 @@ struct ParallelState;
12955
13065
  class TableFilterSet;
12956
13066
 
12957
13067
  struct FunctionOperatorData {
12958
- virtual ~FunctionOperatorData() {
12959
- }
13068
+ DUCKDB_API virtual ~FunctionOperatorData();
12960
13069
  };
12961
13070
 
12962
13071
  struct TableFilterCollection {
13072
+ DUCKDB_API explicit TableFilterCollection(TableFilterSet *table_filters);
13073
+
12963
13074
  TableFilterSet *table_filters;
12964
- explicit TableFilterCollection(TableFilterSet *table_filters) : table_filters(table_filters) {
12965
- }
12966
13075
  };
12967
13076
 
12968
13077
  typedef unique_ptr<FunctionData> (*table_function_bind_t)(ClientContext &context, vector<Value> &inputs,
@@ -13007,6 +13116,7 @@ typedef string (*table_function_to_string_t)(const FunctionData *bind_data);
13007
13116
 
13008
13117
  class TableFunction : public SimpleNamedParameterFunction {
13009
13118
  public:
13119
+ DUCKDB_API
13010
13120
  TableFunction(string name, vector<LogicalType> arguments, table_function_t function,
13011
13121
  table_function_bind_t bind = nullptr, table_function_init_t init = nullptr,
13012
13122
  table_statistics_t statistics = nullptr, table_function_cleanup_t cleanup = nullptr,
@@ -13017,14 +13127,8 @@ public:
13017
13127
  table_function_parallel_t parallel_function = nullptr,
13018
13128
  table_function_init_parallel_t parallel_init = nullptr,
13019
13129
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
13020
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr)
13021
- : SimpleNamedParameterFunction(std::move(name), move(arguments)), bind(bind), init(init), function(function),
13022
- statistics(statistics), cleanup(cleanup), dependency(dependency), cardinality(cardinality),
13023
- pushdown_complex_filter(pushdown_complex_filter), to_string(to_string), max_threads(max_threads),
13024
- init_parallel_state(init_parallel_state), parallel_function(parallel_function), parallel_init(parallel_init),
13025
- parallel_state_next(parallel_state_next), table_scan_progress(query_progress),
13026
- projection_pushdown(projection_pushdown), filter_pushdown(filter_pushdown) {
13027
- }
13130
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
13131
+ DUCKDB_API
13028
13132
  TableFunction(const vector<LogicalType> &arguments, table_function_t function, table_function_bind_t bind = nullptr,
13029
13133
  table_function_init_t init = nullptr, table_statistics_t statistics = nullptr,
13030
13134
  table_function_cleanup_t cleanup = nullptr, table_function_dependency_t dependency = nullptr,
@@ -13035,13 +13139,8 @@ public:
13035
13139
  table_function_parallel_t parallel_function = nullptr,
13036
13140
  table_function_init_parallel_t parallel_init = nullptr,
13037
13141
  table_function_parallel_state_next_t parallel_state_next = nullptr, bool projection_pushdown = false,
13038
- bool filter_pushdown = false, table_function_progress_t query_progress = nullptr)
13039
- : TableFunction(string(), arguments, function, bind, init, statistics, cleanup, dependency, cardinality,
13040
- pushdown_complex_filter, to_string, max_threads, init_parallel_state, parallel_function,
13041
- parallel_init, parallel_state_next, projection_pushdown, filter_pushdown, query_progress) {
13042
- }
13043
- TableFunction() : SimpleNamedParameterFunction("", {}) {
13044
- }
13142
+ bool filter_pushdown = false, table_function_progress_t query_progress = nullptr);
13143
+ DUCKDB_API TableFunction();
13045
13144
 
13046
13145
  //! Bind function
13047
13146
  //! This function is used for determining the return type of a table producing function and returning bind data
@@ -13089,10 +13188,6 @@ public:
13089
13188
  //! Whether or not the table function supports filter pushdown. If not supported a filter will be added
13090
13189
  //! that applies the table filter directly.
13091
13190
  bool filter_pushdown;
13092
-
13093
- string ToString() override {
13094
- return SimpleNamedParameterFunction::ToString();
13095
- }
13096
13191
  };
13097
13192
 
13098
13193
  } // namespace duckdb
@@ -13177,6 +13272,7 @@ namespace duckdb {
13177
13272
  struct ConcurrentQueue;
13178
13273
  struct QueueProducerToken;
13179
13274
  class ClientContext;
13275
+ class DatabaseInstance;
13180
13276
  class TaskScheduler;
13181
13277
 
13182
13278
  struct SchedulerThread;
@@ -13200,6 +13296,7 @@ public:
13200
13296
  ~TaskScheduler();
13201
13297
 
13202
13298
  static TaskScheduler &GetScheduler(ClientContext &context);
13299
+ static TaskScheduler &GetScheduler(DatabaseInstance &db);
13203
13300
 
13204
13301
  unique_ptr<ProducerToken> CreateProducer();
13205
13302
  //! Schedule a task to be executed by the task scheduler
@@ -13444,7 +13541,7 @@ public:
13444
13541
  //! Starts the thread
13445
13542
  void Start();
13446
13543
  //! Stops the thread
13447
- void Stop();
13544
+ void Stop(bool success = true);
13448
13545
  //! Gets current percentage
13449
13546
  int GetCurrentPercentage();
13450
13547
 
@@ -13461,7 +13558,7 @@ private:
13461
13558
  std::condition_variable c;
13462
13559
  mutex m;
13463
13560
  #endif
13464
- idx_t show_progress_after;
13561
+ atomic<idx_t> show_progress_after;
13465
13562
  idx_t time_update_bar;
13466
13563
  atomic<int> current_percentage;
13467
13564
  atomic<bool> stop;
@@ -13547,6 +13644,75 @@ private:
13547
13644
 
13548
13645
  #include <random>
13549
13646
 
13647
+ //===----------------------------------------------------------------------===//
13648
+ // DuckDB
13649
+ //
13650
+ // duckdb/main/client_config.hpp
13651
+ //
13652
+ //
13653
+ //===----------------------------------------------------------------------===//
13654
+
13655
+
13656
+
13657
+
13658
+
13659
+ //===----------------------------------------------------------------------===//
13660
+ // DuckDB
13661
+ //
13662
+ // duckdb/common/enums/output_type.hpp
13663
+ //
13664
+ //
13665
+ //===----------------------------------------------------------------------===//
13666
+
13667
+
13668
+
13669
+
13670
+
13671
+ namespace duckdb {
13672
+
13673
+ enum class ExplainOutputType : uint8_t { ALL = 0, OPTIMIZED_ONLY = 1, PHYSICAL_ONLY = 2 };
13674
+
13675
+ } // namespace duckdb
13676
+
13677
+
13678
+
13679
+ namespace duckdb {
13680
+ class ClientContext;
13681
+
13682
+ struct ClientConfig {
13683
+ //! If the progress bar is enabled or not.
13684
+ bool enable_progress_bar = false;
13685
+ //! If the print of the progress bar is enabled
13686
+ bool print_progress_bar = true;
13687
+ //! The wait time before showing the progress bar
13688
+ int wait_time = 2000;
13689
+
13690
+ // Whether or not aggressive query verification is enabled
13691
+ bool query_verification_enabled = false;
13692
+ //! Enable the running of optimizers
13693
+ bool enable_optimizer = true;
13694
+ //! Force parallelism of small tables, used for testing
13695
+ bool verify_parallelism = false;
13696
+ //! Force index join independent of table cardinality, used for testing
13697
+ bool force_index_join = false;
13698
+ //! Force out-of-core computation for operators that support it, used for testing
13699
+ bool force_external = false;
13700
+ //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13701
+ //! elements)
13702
+ idx_t perfect_ht_threshold = 12;
13703
+
13704
+ //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13705
+ ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13706
+
13707
+ //! Generic options
13708
+ case_insensitive_map_t<Value> set_variables;
13709
+
13710
+ public:
13711
+ static ClientConfig &GetConfig(ClientContext &context);
13712
+ };
13713
+
13714
+ } // namespace duckdb
13715
+
13550
13716
 
13551
13717
  namespace duckdb {
13552
13718
  class Appender;
@@ -13591,35 +13757,12 @@ public:
13591
13757
 
13592
13758
  //! The Progress Bar
13593
13759
  unique_ptr<ProgressBar> progress_bar;
13594
- //! If the progress bar is enabled or not.
13595
- bool enable_progress_bar = false;
13596
- //! If the print of the progress bar is enabled
13597
- bool print_progress_bar = true;
13598
- //! The wait time before showing the progress bar
13599
- int wait_time = 2000;
13600
13760
 
13601
13761
  unique_ptr<SchemaCatalogEntry> temporary_objects;
13602
13762
  unordered_map<string, shared_ptr<PreparedStatementData>> prepared_statements;
13603
13763
 
13604
- case_insensitive_map_t<Value> set_variables;
13605
-
13606
- // Whether or not aggressive query verification is enabled
13607
- bool query_verification_enabled = false;
13608
- //! Enable the running of optimizers
13609
- bool enable_optimizer = true;
13610
- //! Force parallelism of small tables, used for testing
13611
- bool verify_parallelism = false;
13612
- //! Force index join independent of table cardinality, used for testing
13613
- bool force_index_join = false;
13614
- //! Force out-of-core computation for operators that support it, used for testing
13615
- bool force_external = false;
13616
- //! Maximum bits allowed for using a perfect hash table (i.e. the perfect HT can hold up to 2^perfect_ht_threshold
13617
- //! elements)
13618
- idx_t perfect_ht_threshold = 12;
13619
13764
  //! The writer used to log queries (if logging is enabled)
13620
13765
  unique_ptr<BufferedFileWriter> log_query_writer;
13621
- //! The explain output type used when none is specified (default: PHYSICAL_ONLY)
13622
- ExplainOutputType explain_output_type = ExplainOutputType::PHYSICAL_ONLY;
13623
13766
  //! The random generator used by random(). Its seed value can be set by setseed().
13624
13767
  std::mt19937 random_engine;
13625
13768
 
@@ -13627,6 +13770,9 @@ public:
13627
13770
 
13628
13771
  unique_ptr<FileOpener> file_opener;
13629
13772
 
13773
+ //! The client configuration
13774
+ ClientConfig config;
13775
+
13630
13776
  public:
13631
13777
  DUCKDB_API Transaction &ActiveTransaction() {
13632
13778
  return transaction.ActiveTransaction();