Skip to content

Commit dec8593

Browse files
committed
vendor: Update vendored sources to duckdb/duckdb@3240832
V1.2 histrionicus (duckdb/duckdb#16024)
1 parent c5f7ac9 commit dec8593

File tree

36 files changed

+137
-204
lines changed

36 files changed

+137
-204
lines changed

src/duckdb/extension/core_functions/function_list.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ static const StaticFunctionDefinition core_functions[] = {
136136
DUCKDB_AGGREGATE_FUNCTION(CovarPopFun),
137137
DUCKDB_AGGREGATE_FUNCTION(CovarSampFun),
138138
DUCKDB_SCALAR_FUNCTION(CurrentDatabaseFun),
139-
DUCKDB_SCALAR_FUNCTION(CurrentDateFun),
140139
DUCKDB_SCALAR_FUNCTION(CurrentQueryFun),
141140
DUCKDB_SCALAR_FUNCTION(CurrentSchemaFun),
142141
DUCKDB_SCALAR_FUNCTION(CurrentSchemasFun),
@@ -193,7 +192,6 @@ static const StaticFunctionDefinition core_functions[] = {
193192
DUCKDB_SCALAR_FUNCTION_ALIAS(GenRandomUuidFun),
194193
DUCKDB_SCALAR_FUNCTION_SET(GenerateSeriesFun),
195194
DUCKDB_SCALAR_FUNCTION(GetBitFun),
196-
DUCKDB_SCALAR_FUNCTION(CurrentTimeFun),
197195
DUCKDB_SCALAR_FUNCTION(GetCurrentTimestampFun),
198196
DUCKDB_SCALAR_FUNCTION_SET_ALIAS(GradeUpFun),
199197
DUCKDB_SCALAR_FUNCTION_SET(GreatestFun),
@@ -371,7 +369,6 @@ static const StaticFunctionDefinition core_functions[] = {
371369
DUCKDB_SCALAR_FUNCTION(ToTimestampFun),
372370
DUCKDB_SCALAR_FUNCTION(ToWeeksFun),
373371
DUCKDB_SCALAR_FUNCTION(ToYearsFun),
374-
DUCKDB_SCALAR_FUNCTION_ALIAS(TodayFun),
375372
DUCKDB_SCALAR_FUNCTION_ALIAS(TransactionTimestampFun),
376373
DUCKDB_SCALAR_FUNCTION(TranslateFun),
377374
DUCKDB_SCALAR_FUNCTION_SET(TrimFun),

src/duckdb/extension/core_functions/include/core_functions/scalar/date_functions.hpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,6 @@ struct CenturyFun {
3333
static ScalarFunctionSet GetFunctions();
3434
};
3535

36-
struct CurrentDateFun {
37-
static constexpr const char *Name = "current_date";
38-
static constexpr const char *Parameters = "";
39-
static constexpr const char *Description = "Returns the current date";
40-
static constexpr const char *Example = "current_date()";
41-
42-
static ScalarFunction GetFunction();
43-
};
44-
45-
struct TodayFun {
46-
using ALIAS = CurrentDateFun;
47-
48-
static constexpr const char *Name = "today";
49-
};
50-
5136
struct DateDiffFun {
5237
static constexpr const char *Name = "date_diff";
5338
static constexpr const char *Parameters = "part,startdate,enddate";
@@ -198,15 +183,6 @@ struct EpochNsFun {
198183
static ScalarFunctionSet GetFunctions();
199184
};
200185

201-
struct CurrentTimeFun {
202-
static constexpr const char *Name = "get_current_time";
203-
static constexpr const char *Parameters = "";
204-
static constexpr const char *Description = "Returns the current time";
205-
static constexpr const char *Example = "get_current_time()";
206-
207-
static ScalarFunction GetFunction();
208-
};
209-
210186
struct EraFun {
211187
static constexpr const char *Name = "era";
212188
static constexpr const char *Parameters = "ts";

src/duckdb/extension/core_functions/scalar/date/current.cpp

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,41 +27,4 @@ ScalarFunction GetCurrentTimestampFun::GetFunction() {
2727
return current_timestamp;
2828
}
2929

30-
static unique_ptr<Expression> CurrentTimeExpr(FunctionBindExpressionInput &input) {
31-
auto timestamp = GetCurrentTimestampFun::GetFunction();
32-
timestamp.name = GetCurrentTimestampFun::Name;
33-
34-
vector<unique_ptr<Expression>> args;
35-
36-
auto func = make_uniq_base<Expression, BoundFunctionExpression>(LogicalType::TIMESTAMP_TZ, timestamp,
37-
std::move(args), nullptr);
38-
39-
return BoundCastExpression::AddCastToType(input.context, std::move(func), LogicalType::TIME_TZ);
40-
}
41-
42-
static unique_ptr<Expression> CurrentDateExpr(FunctionBindExpressionInput &input) {
43-
auto timestamp = GetCurrentTimestampFun::GetFunction();
44-
timestamp.name = GetCurrentTimestampFun::Name;
45-
46-
vector<unique_ptr<Expression>> args;
47-
48-
auto func = make_uniq_base<Expression, BoundFunctionExpression>(LogicalType::TIMESTAMP_TZ, timestamp,
49-
std::move(args), nullptr);
50-
return BoundCastExpression::AddCastToType(input.context, std::move(func), LogicalType::DATE);
51-
}
52-
53-
ScalarFunction CurrentTimeFun::GetFunction() {
54-
ScalarFunction current_time({}, LogicalType::TIME_TZ, nullptr);
55-
current_time.bind_expression = CurrentTimeExpr;
56-
current_time.stability = FunctionStability::CONSISTENT_WITHIN_QUERY;
57-
return current_time;
58-
}
59-
60-
ScalarFunction CurrentDateFun::GetFunction() {
61-
ScalarFunction current_date({}, LogicalType::DATE, nullptr);
62-
current_date.bind_expression = CurrentDateExpr;
63-
current_date.stability = FunctionStability::CONSISTENT_WITHIN_QUERY;
64-
return current_date;
65-
}
66-
6730
} // namespace duckdb

src/duckdb/extension/parquet/column_writer.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ void BasicColumnWriter::BeginWrite(ColumnWriterState &state_p) {
498498
hdr.data_page_header.repetition_level_encoding = Encoding::RLE;
499499

500500
write_info.temp_writer = make_uniq<MemoryStream>(
501+
Allocator::Get(writer.GetContext()),
501502
MaxValue<idx_t>(NextPowerOfTwo(page_info.estimated_page_size), MemoryStream::DEFAULT_INITIAL_CAPACITY));
502503
write_info.write_count = page_info.empty_count;
503504
write_info.max_write_count = page_info.row_count;
@@ -1469,8 +1470,9 @@ class StandardColumnWriter : public BasicColumnWriter {
14691470
make_uniq<ParquetBloomFilter>(state.dictionary.size(), writer.BloomFilterFalsePositiveRatio());
14701471

14711472
// first write the contents of the dictionary page to a temporary buffer
1472-
auto temp_writer = make_uniq<MemoryStream>(MaxValue<idx_t>(
1473-
NextPowerOfTwo(state.dictionary.size() * sizeof(TGT)), MemoryStream::DEFAULT_INITIAL_CAPACITY));
1473+
auto temp_writer = make_uniq<MemoryStream>(
1474+
Allocator::Get(writer.GetContext()), MaxValue<idx_t>(NextPowerOfTwo(state.dictionary.size() * sizeof(TGT)),
1475+
MemoryStream::DEFAULT_INITIAL_CAPACITY));
14741476
for (idx_t r = 0; r < values.size(); r++) {
14751477
const TGT target_value = OP::template Operation<SRC, TGT>(values[r]);
14761478
// update the statistics
@@ -1844,7 +1846,7 @@ class EnumColumnWriter : public BasicColumnWriter {
18441846
auto enum_count = EnumType::GetSize(enum_type);
18451847
auto string_values = FlatVector::GetData<string_t>(enum_values);
18461848
// first write the contents of the dictionary page to a temporary buffer
1847-
auto temp_writer = make_uniq<MemoryStream>();
1849+
auto temp_writer = make_uniq<MemoryStream>(Allocator::Get(writer.GetContext()));
18481850
for (idx_t r = 0; r < enum_count; r++) {
18491851
D_ASSERT(!FlatVector::IsNull(enum_values, r));
18501852
// update the statistics

src/duckdb/extension/parquet/include/parquet_writer.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ class ParquetWriter {
9191
static duckdb_parquet::Type::type DuckDBTypeToParquetType(const LogicalType &duckdb_type);
9292
static void SetSchemaProperties(const LogicalType &duckdb_type, duckdb_parquet::SchemaElement &schema_ele);
9393

94+
ClientContext &GetContext() {
95+
return context;
96+
}
9497
duckdb_apache::thrift::protocol::TProtocol *GetProtocol() {
9598
return protocol.get();
9699
}
@@ -138,6 +141,7 @@ class ParquetWriter {
138141
void BufferBloomFilter(idx_t col_idx, unique_ptr<ParquetBloomFilter> bloom_filter);
139142

140143
private:
144+
ClientContext &context;
141145
string file_name;
142146
vector<LogicalType> sql_types;
143147
vector<string> column_names;

src/duckdb/extension/parquet/parquet_writer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,9 @@ ParquetWriter::ParquetWriter(ClientContext &context, FileSystem &fs, string file
322322
shared_ptr<ParquetEncryptionConfig> encryption_config_p, idx_t dictionary_size_limit_p,
323323
double bloom_filter_false_positive_ratio_p, int64_t compression_level_p,
324324
bool debug_use_openssl_p, ParquetVersion parquet_version)
325-
: file_name(std::move(file_name_p)), sql_types(std::move(types_p)), column_names(std::move(names_p)), codec(codec),
326-
field_ids(std::move(field_ids_p)), encryption_config(std::move(encryption_config_p)),
327-
dictionary_size_limit(dictionary_size_limit_p),
325+
: context(context), file_name(std::move(file_name_p)), sql_types(std::move(types_p)),
326+
column_names(std::move(names_p)), codec(codec), field_ids(std::move(field_ids_p)),
327+
encryption_config(std::move(encryption_config_p)), dictionary_size_limit(dictionary_size_limit_p),
328328
bloom_filter_false_positive_ratio(bloom_filter_false_positive_ratio_p), compression_level(compression_level_p),
329329
debug_use_openssl(debug_use_openssl_p), parquet_version(parquet_version) {
330330

src/duckdb/src/catalog/catalog_set.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
353353
// push the old entry in the undo buffer for this transaction
354354
if (transaction.transaction) {
355355
// serialize the AlterInfo into a temporary buffer
356-
MemoryStream stream;
356+
MemoryStream stream(Allocator::Get(*transaction.db));
357357
BinarySerializer serializer(stream);
358358
serializer.Begin();
359359
serializer.WriteProperty(100, "column_name", alter_info.GetColumnName());

src/duckdb/src/common/serializer/memory_stream.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44

55
namespace duckdb {
66

7-
MemoryStream::MemoryStream(idx_t capacity) : position(0), capacity(capacity), owns_data(true) {
7+
MemoryStream::MemoryStream(Allocator &allocator_p, idx_t capacity)
8+
: allocator(&allocator_p), position(0), capacity(capacity) {
89
D_ASSERT(capacity != 0 && IsPowerOfTwo(capacity));
9-
data = Allocator::DefaultAllocatorReference()->AllocateData(capacity);
10+
data = allocator_p.AllocateData(capacity);
1011
}
1112

12-
MemoryStream::MemoryStream(data_ptr_t buffer, idx_t capacity)
13-
: position(0), capacity(capacity), owns_data(false), data(buffer) {
13+
MemoryStream::MemoryStream(idx_t capacity) : MemoryStream(Allocator::DefaultAllocator(), capacity) {
14+
}
15+
16+
MemoryStream::MemoryStream(data_ptr_t buffer, idx_t capacity) : position(0), capacity(capacity), data(buffer) {
1417
}
1518

1619
MemoryStream::~MemoryStream() {
17-
if (owns_data) {
18-
Allocator::DefaultAllocatorReference()->FreeData(data, capacity);
20+
if (allocator && data) {
21+
allocator->FreeData(data, capacity);
1922
}
2023
}
2124

@@ -24,48 +27,48 @@ MemoryStream::MemoryStream(MemoryStream &&other) noexcept {
2427
data = other.data;
2528
position = other.position;
2629
capacity = other.capacity;
27-
owns_data = other.owns_data;
30+
allocator = other.allocator;
2831

2932
// Reset the other stream
3033
other.data = nullptr;
3134
other.position = 0;
3235
other.capacity = 0;
33-
other.owns_data = false;
36+
other.allocator = nullptr;
3437
}
3538

3639
MemoryStream &MemoryStream::operator=(MemoryStream &&other) noexcept {
3740
if (this != &other) {
3841
// Free the current data
39-
if (owns_data) {
40-
Allocator::DefaultAllocatorReference()->FreeData(data, capacity);
42+
if (allocator) {
43+
allocator->FreeData(data, capacity);
4144
}
4245

4346
// Move the data from the other stream into this stream
4447
data = other.data;
4548
position = other.position;
4649
capacity = other.capacity;
47-
owns_data = other.owns_data;
50+
allocator = other.allocator;
4851

4952
// Reset the other stream
5053
other.data = nullptr;
5154
other.position = 0;
5255
other.capacity = 0;
53-
other.owns_data = false;
56+
other.allocator = nullptr;
5457
}
5558
return *this;
5659
}
5760

5861
void MemoryStream::WriteData(const_data_ptr_t source, idx_t write_size) {
5962
const auto old_capacity = capacity;
6063
while (position + write_size > capacity) {
61-
if (owns_data) {
64+
if (allocator) {
6265
capacity *= 2;
6366
} else {
6467
throw SerializationException("Failed to serialize: not enough space in buffer to fulfill write request");
6568
}
6669
}
6770
if (capacity != old_capacity) {
68-
data = Allocator::DefaultAllocatorReference()->ReallocateData(data, old_capacity, capacity);
71+
data = allocator->ReallocateData(data, old_capacity, capacity);
6972
}
7073
memcpy(data + position, source, write_size);
7174
position += write_size;
@@ -84,7 +87,7 @@ void MemoryStream::Rewind() {
8487
}
8588

8689
void MemoryStream::Release() {
87-
owns_data = false;
90+
allocator = nullptr;
8891
}
8992

9093
data_ptr_t MemoryStream::GetData() const {

src/duckdb/src/common/types/bit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void Bit::BitToBlob(bitstring_t bit, string_t &output_blob) {
179179
auto output = output_blob.GetDataWriteable();
180180
idx_t size = output_blob.GetSize();
181181

182-
output[0] = UnsafeNumericCast<char>(GetFirstByte(bit));
182+
output[0] = static_cast<char>(GetFirstByte(bit));
183183
if (size >= 2) {
184184
++output;
185185
// First byte in bitstring contains amount of padded bits,

src/duckdb/src/common/types/data_chunk.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ void DataChunk::Verify() {
369369
}
370370

371371
// verify that we can round-trip chunk serialization
372-
MemoryStream mem_stream;
372+
Allocator allocator;
373+
MemoryStream mem_stream(allocator);
373374
BinarySerializer serializer(mem_stream);
374375

375376
serializer.Begin();

0 commit comments

Comments
 (0)