Skip to content

Commit

Permalink
Update vendored DuckDB sources to 412147b
Browse files Browse the repository at this point in the history
  • Loading branch information
duckdblabs-bot committed Sep 6, 2024
1 parent 412147b commit ebcae2f
Show file tree
Hide file tree
Showing 36 changed files with 155 additions and 100 deletions.
13 changes: 12 additions & 1 deletion src/duckdb/extension/json/json_functions/json_create.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ static void CreateValues(const StructNames &names, yyjson_mut_doc *doc, yyjson_m
case LogicalTypeId::TIMESTAMP_NS:
case LogicalTypeId::TIMESTAMP_MS:
case LogicalTypeId::TIMESTAMP_SEC:
case LogicalTypeId::VARINT:
case LogicalTypeId::UUID: {
Vector string_vector(LogicalTypeId::VARCHAR, count);
VectorOperations::DefaultCast(value_v, string_vector, count);
Expand All @@ -562,7 +563,17 @@ static void CreateValues(const StructNames &names, yyjson_mut_doc *doc, yyjson_m
TemplatedCreateValues<double, double>(doc, vals, double_vector, count);
break;
}
default:
case LogicalTypeId::INVALID:
case LogicalTypeId::UNKNOWN:
case LogicalTypeId::ANY:
case LogicalTypeId::USER:
case LogicalTypeId::CHAR:
case LogicalTypeId::STRING_LITERAL:
case LogicalTypeId::INTEGER_LITERAL:
case LogicalTypeId::POINTER:
case LogicalTypeId::VALIDITY:
case LogicalTypeId::TABLE:
case LogicalTypeId::LAMBDA:
throw InternalException("Unsupported type arrived at JSON create function");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ static void ReadJSONObjectsFunction(ClientContext &context, TableFunctionInput &

if (!gstate.names.empty()) {
// Create the strings without copying them
auto strings = FlatVector::GetData<string_t>(output.data[0]);
auto &validity = FlatVector::Validity(output.data[0]);
const auto col_idx = gstate.column_indices[0];
auto strings = FlatVector::GetData<string_t>(output.data[col_idx]);
auto &validity = FlatVector::Validity(output.data[col_idx]);
for (idx_t i = 0; i < count; i++) {
if (objects[i]) {
strings[i] = string_t(units[i].pointer, units[i].size);
Expand Down
13 changes: 8 additions & 5 deletions src/duckdb/src/common/types/varint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ bool Varint::VarcharFormatting(const string_t &value, idx_t &start_pos, idx_t &e
is_zero = true;
return true;
}
// This is either a '+' or '-'. Hence invalid.
// This is either a '+' or '-'. Hence, invalid.
return false;
}
idx_t cur_pos = start_pos;
Expand Down Expand Up @@ -262,17 +262,16 @@ string Varint::VarcharToVarInt(const string_t &value) {
return result;
}

bool Varint::VarintToDouble(string_t &blob, double &result, bool &strict) {
bool Varint::VarintToDouble(const string_t &blob, double &result, bool &strict) {
result = 0;
bool is_negative;

if (blob.GetSize() < 4) {
throw InvalidInputException("Invalid blob size.");
}
auto blob_ptr = blob.GetData();

// Determine if the number is negative
is_negative = (blob_ptr[0] & 0x80) == 0;
bool is_negative = (blob_ptr[0] & 0x80) == 0;
idx_t byte_pos = 0;
for (idx_t i = blob.GetSize() - 1; i > 2; i--) {
if (is_negative) {
Expand All @@ -286,7 +285,11 @@ bool Varint::VarintToDouble(string_t &blob, double &result, bool &strict) {
if (is_negative) {
result *= -1;
}
return std::isfinite(result);
if (!std::isfinite(result)) {
// We throw an error
throw ConversionException("Could not convert varint '%s' to Double", VarIntToVarchar(blob));
}
return true;
}

} // namespace duckdb
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 @@ -476,7 +476,7 @@ static void UUIDConversion(Vector &vector, const ArrowArray &array, const ArrowS
if (!validity_mask.RowIsValid(row)) {
continue;
}
tgt_ptr[row].lower = BSwap(src_ptr[row].upper);
tgt_ptr[row].lower = static_cast<uint64_t>(BSwap(src_ptr[row].upper));
// flip Upper MSD
tgt_ptr[row].upper =
static_cast<int64_t>(static_cast<uint64_t>(BSwap(src_ptr[row].lower)) ^ (static_cast<uint64_t>(1) << 63));
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 "1-dev5190"
#define DUCKDB_PATCH_VERSION "1-dev5272"
#endif
#ifndef DUCKDB_MINOR_VERSION
#define DUCKDB_MINOR_VERSION 0
Expand All @@ -8,10 +8,10 @@
#define DUCKDB_MAJOR_VERSION 1
#endif
#ifndef DUCKDB_VERSION
#define DUCKDB_VERSION "v1.0.1-dev5190"
#define DUCKDB_VERSION "v1.0.1-dev5272"
#endif
#ifndef DUCKDB_SOURCE_ID
#define DUCKDB_SOURCE_ID "ee74ca92ff"
#define DUCKDB_SOURCE_ID "4d18b9d05c"
#endif
#include "duckdb/function/table/system_functions.hpp"
#include "duckdb/main/database.hpp"
Expand Down
8 changes: 8 additions & 0 deletions src/duckdb/src/include/duckdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
//! duplicate of duckdb/main/winapi.hpp
#ifndef DUCKDB_API
#ifdef _WIN32
#ifdef DUCKDB_STATIC_BUILD
#define DUCKDB_API
#else
#if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
#define DUCKDB_API __declspec(dllexport)
#else
#define DUCKDB_API __declspec(dllimport)
#endif
#endif
#else
#define DUCKDB_API
#endif
Expand All @@ -29,11 +33,15 @@
//! duplicate of duckdb/main/winapi.hpp
#ifndef DUCKDB_EXTENSION_API
#ifdef _WIN32
#ifdef DUCKDB_STATIC_BUILD
#define DUCKDB_EXTENSION_API
#else
#ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
#define DUCKDB_EXTENSION_API __declspec(dllexport)
#else
#define DUCKDB_EXTENSION_API
#endif
#endif
#else
#define DUCKDB_EXTENSION_API __attribute__((visibility("default")))
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/duckdb/src/include/duckdb/common/types/varint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Varint {
//! Function to convert Varchar to VARINT blob
DUCKDB_API static string VarcharToVarInt(const string_t &value);
//! ----------------------------------- Double Cast ----------------------------------- //
DUCKDB_API static bool VarintToDouble(string_t &blob, double &result, bool &strict);
DUCKDB_API static bool VarintToDouble(const string_t &blob, double &result, bool &strict);
};

//! ----------------------------------- (u)Integral Cast ----------------------------------- //
Expand Down
8 changes: 8 additions & 0 deletions src/duckdb/src/include/duckdb/common/winapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@

#ifndef DUCKDB_API
#if defined(_WIN32) && !defined(__MINGW32__)
#ifdef DUCKDB_STATIC_BUILD
#define DUCKDB_API
#else
#if defined(DUCKDB_BUILD_LIBRARY) && !defined(DUCKDB_BUILD_LOADABLE_EXTENSION)
#define DUCKDB_API __declspec(dllexport)
#else
#define DUCKDB_API __declspec(dllimport)
#endif
#endif
#else
#define DUCKDB_API
#endif
#endif

#ifndef DUCKDB_EXTENSION_API
#ifdef _WIN32
#ifdef DUCKDB_STATIC_BUILD
#define DUCKDB_EXTENSION_API
#else
#ifdef DUCKDB_BUILD_LOADABLE_EXTENSION
#define DUCKDB_EXTENSION_API __declspec(dllexport)
#else
#define DUCKDB_EXTENSION_API
#endif
#endif
#else
#define DUCKDB_EXTENSION_API __attribute__((visibility("default")))
#endif
Expand Down
1 change: 1 addition & 0 deletions src/duckdb/src/include/duckdb/main/extension_entries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
{"pg_connection_limit", "postgres_scanner"},
{"pg_debug_show_queries", "postgres_scanner"},
{"pg_experimental_filter_pushdown", "postgres_scanner"},
{"pg_null_byte_replacement", "postgres_scanner"},
{"pg_pages_per_task", "postgres_scanner"},
{"pg_use_binary_copy", "postgres_scanner"},
{"pg_use_ctid_scan", "postgres_scanner"},
Expand Down
14 changes: 8 additions & 6 deletions src/duckdb/src/include/duckdb/parser/transformer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ class Transformer {
// Statement transformation
//===--------------------------------------------------------------------===//
//! Transform a Postgres duckdb_libpgquery::T_PGSelectStmt node into a SelectStatement
unique_ptr<SelectStatement> TransformSelect(optional_ptr<duckdb_libpgquery::PGNode> node, bool is_select = true);
//! Transform a Postgres duckdb_libpgquery::T_PGSelectStmt node into a SelectStatement
unique_ptr<SelectStatement> TransformSelect(duckdb_libpgquery::PGSelectStmt &select, bool is_select = true);
unique_ptr<SelectStatement> TransformSelectStmt(duckdb_libpgquery::PGSelectStmt &select, bool is_select = true);
unique_ptr<SelectStatement> TransformSelectStmt(duckdb_libpgquery::PGNode &node, bool is_select = true);
//! Transform a Postgres T_AlterStmt node into a AlterStatement
unique_ptr<AlterStatement> TransformAlter(duckdb_libpgquery::PGAlterTableStmt &stmt);
//! Transform a Postgres duckdb_libpgquery::T_PGRenameStmt node into a RenameStatement
Expand Down Expand Up @@ -170,8 +169,10 @@ class Transformer {
unique_ptr<PragmaStatement> TransformImport(duckdb_libpgquery::PGImportStmt &stmt);
unique_ptr<ExplainStatement> TransformExplain(duckdb_libpgquery::PGExplainStmt &stmt);
unique_ptr<SQLStatement> TransformVacuum(duckdb_libpgquery::PGVacuumStmt &stmt);
unique_ptr<SelectStatement> TransformShow(duckdb_libpgquery::PGVariableShowStmt &stmt);
unique_ptr<SelectStatement> TransformShowSelect(duckdb_libpgquery::PGVariableShowSelectStmt &stmt);
unique_ptr<QueryNode> TransformShow(duckdb_libpgquery::PGVariableShowStmt &stmt);
unique_ptr<SelectStatement> TransformShowStmt(duckdb_libpgquery::PGVariableShowStmt &stmt);
unique_ptr<QueryNode> TransformShowSelect(duckdb_libpgquery::PGVariableShowSelectStmt &stmt);
unique_ptr<SelectStatement> TransformShowSelectStmt(duckdb_libpgquery::PGVariableShowSelectStmt &stmt);
unique_ptr<AttachStatement> TransformAttach(duckdb_libpgquery::PGAttachStmt &stmt);
unique_ptr<DetachStatement> TransformDetach(duckdb_libpgquery::PGDetachStmt &stmt);
unique_ptr<SetStatement> TransformUse(duckdb_libpgquery::PGUseStmt &stmt);
Expand Down Expand Up @@ -204,7 +205,8 @@ class Transformer {
// Query Node Transform
//===--------------------------------------------------------------------===//
//! Transform a Postgres duckdb_libpgquery::T_PGSelectStmt node into a QueryNode
unique_ptr<QueryNode> TransformSelectNode(duckdb_libpgquery::PGSelectStmt &select);
unique_ptr<QueryNode> TransformSelectNode(duckdb_libpgquery::PGNode &select, bool is_select = true);
unique_ptr<QueryNode> TransformSelectNodeInternal(duckdb_libpgquery::PGSelectStmt &select, bool is_select = true);
unique_ptr<QueryNode> TransformSelectInternal(duckdb_libpgquery::PGSelectStmt &select);
void TransformModifiers(duckdb_libpgquery::PGSelectStmt &stmt, QueryNode &node);

Expand Down
4 changes: 2 additions & 2 deletions src/duckdb/src/include/duckdb/planner/expression_binder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ class ExpressionBinder {
static LogicalType GetExpressionReturnType(const Expression &expr);

private:
//! Maximum stack depth
static constexpr const idx_t MAXIMUM_STACK_DEPTH = 128;
//! Current stack depth
idx_t stack_depth = DConstants::INVALID_INDEX;

Expand Down Expand Up @@ -204,6 +202,8 @@ class ExpressionBinder {
virtual BindResult BindUnnest(FunctionExpression &expr, idx_t depth, bool root_expression);
virtual BindResult BindMacro(FunctionExpression &expr, ScalarMacroCatalogEntry &macro, idx_t depth,
unique_ptr<ParsedExpression> &expr_ptr);
void UnfoldMacroExpression(FunctionExpression &function, ScalarMacroCatalogEntry &macro_func,
unique_ptr<ParsedExpression> &expr);

virtual string UnsupportedAggregateMessage();
virtual string UnsupportedUnnestMessage();
Expand Down
4 changes: 3 additions & 1 deletion src/duckdb/src/main/buffered_data/simple_buffered_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ StreamExecutionResult SimpleBufferedData::ExecuteTaskInternal(StreamQueryResult
if (!cc) {
return StreamExecutionResult::EXECUTION_CANCELLED;
}

if (!cc->IsActiveResult(context_lock, result)) {
return StreamExecutionResult::EXECUTION_CANCELLED;
}
if (BufferIsFull()) {
// The buffer isn't empty yet, just return
return StreamExecutionResult::CHUNK_READY;
Expand Down
11 changes: 0 additions & 11 deletions src/duckdb/src/main/extension/extension_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,17 +770,6 @@ EMS5gLv50CzQqJXK9mNzPuYXNUIc4Pw4ssVWe0OfN3Od90gl5uFUwk/G9lWSYnBN
static const char *const community_public_keys[] = {
R"(
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv+Jki3aiZt0eOzShgD2g
BYPjPpkhHowOwPzUKtTVPob7vxyzd2wPyWDF/Zn6sN8QzravAdlXFE3SNF7ayO86
IPHhMxO6P2YlxbipyKzPOUJsasXBiwYw2aSvb0RtwnYwD5lJs8Tz2ET1RQCFgXGc
LW7bDjKRbHSME0Me5rLRWVztOqULeoMeY1oCOmKKeAYxjFOASJJfQF9oQxkuu3j1
qpcXnfHldlPGzFM77OFlWFtlc9QW4WNoxkO3HwskFW6ZRaQipM8vgSzkIfPFESGL
TtDRw+RcUPqmS6NVW8nhaiptBIMXy+9cP/l1LGmGwrZRhWP0YBlk6V9MUMzjyo+R
JQIDAQAB
-----END PUBLIC KEY-----
)",
R"(
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtXl28loGwAH3ZGQXXgJQ
3omhIEiUb3z9Petjl+jmdtEQnMNUFEZiXkfJB02UFWBL1OoKKnjiGhcr5oGiIZKR
CoaL6SfmWe//7o8STM44stE0exzZcv8W4tWwjrzSWQnwh2JgSnHN64xoDQjdvG3X
Expand Down
6 changes: 3 additions & 3 deletions src/duckdb/src/parser/parsed_data/create_index_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ CreateIndexInfo::CreateIndexInfo() : CreateInfo(CatalogType::INDEX_ENTRY, INVALI
}

CreateIndexInfo::CreateIndexInfo(const duckdb::CreateIndexInfo &info)
: CreateInfo(CatalogType::INDEX_ENTRY), table(info.table), index_name(info.index_name), options(info.options),
index_type(info.index_type), constraint_type(info.constraint_type), column_ids(info.column_ids),
scan_types(info.scan_types), names(info.names) {
: CreateInfo(CatalogType::INDEX_ENTRY, info.schema), table(info.table), index_name(info.index_name),
options(info.options), index_type(info.index_type), constraint_type(info.constraint_type),
column_ids(info.column_ids), scan_types(info.scan_types), names(info.names) {
}

static void RemoveTableQualificationRecursive(unique_ptr<ParsedExpression> &expr, const string &table_name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void RemoveOrderQualificationRecursive(unique_ptr<ParsedExpression> &expr) {
unique_ptr<ParsedExpression> Transformer::TransformSubquery(duckdb_libpgquery::PGSubLink &root) {
auto subquery_expr = make_uniq<SubqueryExpression>();

subquery_expr->subquery = TransformSelect(root.subselect);
subquery_expr->subquery = TransformSelectStmt(*root.subselect);
SetQueryLocation(*subquery_expr, root.location);
D_ASSERT(subquery_expr->subquery);
D_ASSERT(!subquery_expr->subquery->node->GetSelectList().empty());
Expand Down
15 changes: 9 additions & 6 deletions src/duckdb/src/parser/transform/helpers/transform_cte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ void Transformer::TransformCTE(duckdb_libpgquery::PGWithClause &de_with_clause,
info->query = TransformRecursiveCTE(cte, *info);
} else {
Transformer cte_transformer(*this);
info->query =
cte_transformer.TransformSelect(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(cte.ctequery));
info->query = cte_transformer.TransformSelectStmt(*cte.ctequery);
}
D_ASSERT(info->query);
auto cte_name = string(cte.ctename);
Expand Down Expand Up @@ -114,16 +113,20 @@ unique_ptr<SelectStatement> Transformer::TransformRecursiveCTE(duckdb_libpgquery
auto with_clause = PGPointerCast<duckdb_libpgquery::PGWithClause>(stmt.withClause);
TransformCTE(*with_clause, result.cte_map);
}
result.left = TransformSelectNode(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(stmt.larg));
result.right = TransformSelectNode(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(stmt.rarg));
result.left = TransformSelectNode(*stmt.larg);
result.right = TransformSelectNode(*stmt.rarg);
result.aliases = info.aliases;
break;
}
case duckdb_libpgquery::PG_SETOP_EXCEPT:
case duckdb_libpgquery::PG_SETOP_INTERSECT:
default:
default: {
// This CTE is not recursive. Fallback to regular query transformation.
return TransformSelect(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(cte.ctequery));
auto node = TransformSelectNode(*cte.ctequery);
auto result = make_uniq<SelectStatement>();
result->node = std::move(node);
return result;
}
}

if (stmt.limitCount || stmt.limitOffset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ unique_ptr<CopyStatement> Transformer::TransformCopy(duckdb_libpgquery::PGCopySt
info.schema = table.schema_name;
info.catalog = table.catalog_name;
} else {
info.select_statement = TransformSelectNode(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(stmt.query));
info.select_statement = TransformSelectNode(*stmt.query);
}

// handle the different options of the COPY statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ unique_ptr<MacroFunction> Transformer::TransformMacroFunction(duckdb_libpgquery:
auto expression = TransformExpression(def.function);
macro_func = make_uniq<ScalarMacroFunction>(std::move(expression));
} else if (def.query) {
auto query_node =
TransformSelect(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(def.query), true)->node->Copy();
auto query_node = TransformSelectNode(*def.query);
macro_func = make_uniq<TableMacroFunction>(std::move(query_node));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateTableAs(duckdb_libpgquer
if (stmt.query->type != duckdb_libpgquery::T_PGSelectStmt) {
throw ParserException("CREATE TABLE AS requires a SELECT clause");
}
auto query = TransformSelect(stmt.query, false);
auto query = TransformSelectStmt(*stmt.query, false);

auto result = make_uniq<CreateStatement>();
auto info = make_uniq<CreateTableInfo>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateType(duckdb_libpgquery::
if (stmt.query) {
// CREATE TYPE mood AS ENUM (SELECT ...)
D_ASSERT(stmt.vals == nullptr);
auto query = TransformSelect(stmt.query, false);
auto query = TransformSelectStmt(*stmt.query, false);
info->query = std::move(query);
info->type = LogicalType::INVALID;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateView(duckdb_libpgquery::
}
info->on_conflict = TransformOnConflict(stmt.onconflict);

info->query = TransformSelect(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(stmt.query), false);
info->query = TransformSelectStmt(*PGPointerCast<duckdb_libpgquery::PGSelectStmt>(stmt.query), false);

PivotEntryCheck("view");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ unique_ptr<InsertStatement> Transformer::TransformInsert(duckdb_libpgquery::PGIn
TransformExpressionList(*stmt.returningList, result->returning_list);
}
if (stmt.selectStmt) {
result->select_statement = TransformSelect(stmt.selectStmt, false);
result->select_statement = TransformSelectStmt(*stmt.selectStmt, false);
} else {
result->default_values = true;
}
Expand Down
Loading

0 comments on commit ebcae2f

Please sign in to comment.