Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/duckdb/extension/core_functions/scalar/string/repeat.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "duckdb/common/vector_operations/binary_executor.hpp"
#include "core_functions/scalar/string_functions.hpp"
#include "duckdb/common/operator/add.hpp"
#include "duckdb/common/operator/multiply.hpp"

namespace duckdb {
Expand Down Expand Up @@ -42,8 +43,16 @@ static void RepeatListFunction(DataChunk &args, ExpressionState &, Vector &resul
BinaryExecutor::Execute<list_entry_t, int64_t, list_entry_t>(
list_vector, cnt_vector, result, args.size(), [&](list_entry_t list_input, int64_t cnt) {
idx_t copy_count = cnt <= 0 || list_input.length == 0 ? 0 : UnsafeNumericCast<idx_t>(cnt);
idx_t result_length = list_input.length * copy_count;
idx_t new_size = current_size + result_length;
idx_t result_length;
if (!TryMultiplyOperator::Operation(list_input.length, copy_count, result_length)) {
throw OutOfRangeException("Cannot create a list of size: '%d' * '%d', the result is too large",
list_input.length, copy_count);
}
idx_t new_size;
if (!TryAddOperator::Operation(current_size, result_length, new_size)) {
throw OutOfRangeException("Cannot create a list of size: '%d' + '%d', the result is too large",
current_size, result_length);
}
ListVector::Reserve(result, new_size);
list_entry_t result_list;
result_list.offset = current_size;
Expand Down
14 changes: 12 additions & 2 deletions src/duckdb/src/common/types/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,19 @@ class TextWriter {
buffer.push_back(c);
}
void Write(double value) {
auto start = buffer.size();
duckdb_fmt::format_to(std::back_inserter(buffer), "{}", value);
// Remove trailing zero
if (buffer.back() == '0') {
// Remove trailing ".0" (e.g. "10.0" -> "10"), but only when the number
// is in fixed notation. Scientific notation like "1e+20" must not be
// touched — stripping the trailing '0' would corrupt the exponent.
bool has_exponent = false;
for (auto i = start; i < buffer.size(); i++) {
if (buffer[i] == 'e' || buffer[i] == 'E') {
has_exponent = true;
break;
}
}
if (!has_exponent && buffer.back() == '0') {
buffer.pop_back();
if (buffer.back() == '.') {
buffer.pop_back();
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/function/table/arrow_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ void ArrowToDuckDBConversion::ColumnArrowToDuckDBRunEndEncoded(Vector &vector, c
FlattenRunEndsSwitch<int32_t>(vector, run_end_encoding, compressed_size, scan_offset, size);
break;
case PhysicalType::INT64:
FlattenRunEndsSwitch<int32_t>(vector, run_end_encoding, compressed_size, scan_offset, size);
FlattenRunEndsSwitch<int64_t>(vector, run_end_encoding, compressed_size, scan_offset, size);
break;
default:
throw NotImplementedException("Type '%s' not implemented for RunEndEncoding", TypeIdToString(physical_type));
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/function/table/version/pragma_version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef DUCKDB_PATCH_VERSION
#define DUCKDB_PATCH_VERSION "2-dev408"
#define DUCKDB_PATCH_VERSION "2-dev419"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 5
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.5.2-dev408"
#define DUCKDB_VERSION "v1.5.2-dev419"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "cbc6f2230e"
#define DUCKDB_SOURCE_ID "c241da23ae"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/main/database_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ optional_ptr<AttachedDatabase> DatabaseManager::FinalizeAttach(ClientContext &co
}

void DatabaseManager::DetachDatabase(ClientContext &context, const string &name, OnEntryNotFound if_not_found) {
if (GetDefaultDatabase(context) == name) {
if (StringUtil::CIEquals(GetDefaultDatabase(context), name)) {
throw BinderException("Cannot detach database \"%s\" because it is the default database. Select a different "
"database using `USE` to allow detaching this database",
name);
Expand Down Expand Up @@ -305,7 +305,7 @@ void DatabaseManager::RenameDatabase(ClientContext &context, const string &old_n
databases[new_name] = attached_db;
}

if (default_database == old_name) {
if (StringUtil::CIEquals(default_database, old_name)) {
default_database = new_name;
}
}
Expand Down
1 change: 1 addition & 0 deletions src/duckdb/src/parser/parsed_data/create_view_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ unique_ptr<CreateInfo> CreateViewInfo::Copy() const {
CopyProperties(*result);
result->aliases = aliases;
result->types = types;
result->names = names;
result->column_comments_map = column_comments_map;
result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
return std::move(result);
Expand Down
Loading