From d1c7caf55632fd357767bd4e6d998d4421473391 Mon Sep 17 00:00:00 2001 From: "Y." Date: Mon, 25 Nov 2024 09:31:42 -0500 Subject: [PATCH] Fail compilation on warnings (#439) * fail compilation on warnings (`-Werror`) * remove unused parameters * fix integer comparisons --- .github/workflows/build_and_test.yaml | 5 +- Makefile | 13 +- include/pgduckdb/pgduckdb_ddl.hpp | 2 +- include/pgduckdb/pgduckdb_utils.hpp | 5 +- include/pgduckdb/scan/postgres_scan.hpp | 2 +- include/pgduckdb/types/decimal.hpp | 4 +- include/pgduckdb/utility/allocator.hpp | 2 +- src/catalog/pgduckdb_catalog.cpp | 53 ++++---- src/catalog/pgduckdb_schema.cpp | 43 +++---- src/catalog/pgduckdb_storage.cpp | 3 +- src/catalog/pgduckdb_table.cpp | 22 ++-- src/catalog/pgduckdb_transaction.cpp | 10 +- src/catalog/pgduckdb_transaction_manager.cpp | 7 +- src/pgduckdb_background_worker.cpp | 6 +- src/pgduckdb_ddl.cpp | 6 +- src/pgduckdb_detoast.cpp | 4 + src/pgduckdb_hooks.cpp | 2 +- src/pgduckdb_metadata_cache.cpp | 4 +- src/pgduckdb_node.cpp | 10 +- src/pgduckdb_planner.cpp | 6 +- src/pgduckdb_table_am.cpp | 122 ++++++++++--------- src/pgduckdb_types.cpp | 22 ++-- src/pgduckdb_xact.cpp | 2 +- src/scan/postgres_scan.cpp | 4 +- src/scan/postgres_seq_scan.cpp | 12 +- src/vendor/pg_ruleutils_14.c | 4 + src/vendor/pg_ruleutils_15.c | 4 + src/vendor/pg_ruleutils_16.c | 4 + src/vendor/pg_ruleutils_17.c | 4 + 29 files changed, 203 insertions(+), 184 deletions(-) diff --git a/.github/workflows/build_and_test.yaml b/.github/workflows/build_and_test.yaml index c4f437ae..8d0efa41 100644 --- a/.github/workflows/build_and_test.yaml +++ b/.github/workflows/build_and_test.yaml @@ -110,9 +110,8 @@ jobs: - name: Build pg_duckdb extension id: build - run: | - pushd duckdb - make -j8 install + working-directory: duckdb + run: ERROR_ON_WARNING=1 make -j8 install - name: Run make installcheck id: installcheck diff --git a/Makefile b/Makefile index afef3475..afcf246b 100644 --- a/Makefile +++ b/Makefile @@ -35,8 +35,17 @@ endif DUCKDB_LIB = libduckdb$(DLSUFFIX) FULL_DUCKDB_LIB = third_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src/$(DUCKDB_LIB) -override PG_CPPFLAGS += -Iinclude -Ithird_party/duckdb/src/include -Ithird_party/duckdb/third_party/re2 -override PG_CXXFLAGS += -std=c++17 -Wno-sign-compare -Wno-register ${DUCKDB_BUILD_CXX_FLAGS} +ERROR_ON_WARNING ?= +ifeq ($(ERROR_ON_WARNING), 1) + ERROR_ON_WARNING = -Werror +else + ERROR_ON_WARNING = +endif + +COMPILER_FLAGS=-Wno-sign-compare -Wno-register -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas -Wall -Wextra ${ERROR_ON_WARNING} + +override PG_CPPFLAGS += -Iinclude -isystem third_party/duckdb/src/include -isystem third_party/duckdb/third_party/re2 ${COMPILER_FLAGS} +override PG_CXXFLAGS += -std=c++17 ${DUCKDB_BUILD_CXX_FLAGS} ${COMPILER_FLAGS} SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lduckdb -lstdc++ -llz4 diff --git a/include/pgduckdb/pgduckdb_ddl.hpp b/include/pgduckdb/pgduckdb_ddl.hpp index 7bbd1bba..b08d8de9 100644 --- a/include/pgduckdb/pgduckdb_ddl.hpp +++ b/include/pgduckdb/pgduckdb_ddl.hpp @@ -2,5 +2,5 @@ #include "pgduckdb/pg/declarations.hpp" -void DuckdbHandleDDL(Node *ParseTree, const char *queryString); +void DuckdbHandleDDL(Node *ParseTree); void DuckdbTruncateTable(Oid relation_oid); diff --git a/include/pgduckdb/pgduckdb_utils.hpp b/include/pgduckdb/pgduckdb_utils.hpp index dbc198ac..345f8352 100644 --- a/include/pgduckdb/pgduckdb_utils.hpp +++ b/include/pgduckdb/pgduckdb_utils.hpp @@ -88,9 +88,8 @@ __CPPFunctionGuard__(const char *func_name, FuncArgs... args) { Datum func_name##_cpp(PG_FUNCTION_ARGS); \ Datum func_name(PG_FUNCTION_ARGS) { \ return InvokeCPPFunc(func_name##_cpp, fcinfo); \ - } \ - Datum func_name##_cpp(PG_FUNCTION_ARGS) - + } \ + Datum func_name##_cpp(PG_FUNCTION_ARGS __attribute__((unused))) duckdb::unique_ptr DuckDBQueryOrThrow(duckdb::ClientContext &context, const std::string &query); diff --git a/include/pgduckdb/scan/postgres_scan.hpp b/include/pgduckdb/scan/postgres_scan.hpp index defbdfb9..85fdf86e 100644 --- a/include/pgduckdb/scan/postgres_scan.hpp +++ b/include/pgduckdb/scan/postgres_scan.hpp @@ -43,7 +43,7 @@ class PostgresScanLocalState { } } - int m_output_vector_size; + uint32_t m_output_vector_size; bool m_exhausted_scan; std::vector> values; std::vector> nulls; diff --git a/include/pgduckdb/types/decimal.hpp b/include/pgduckdb/types/decimal.hpp index fa1af84f..6cd69516 100644 --- a/include/pgduckdb/types/decimal.hpp +++ b/include/pgduckdb/types/decimal.hpp @@ -294,7 +294,7 @@ struct DecimalConversionInteger { template static T - Finalize(const NumericVar &numeric, T result) { + Finalize(const NumericVar &, T result) { return result; } }; @@ -349,7 +349,7 @@ struct DecimalConversionHugeint { } static hugeint_t - Finalize(const NumericVar &numeric, hugeint_t result) { + Finalize(const NumericVar &, hugeint_t result) { return result; } }; diff --git a/include/pgduckdb/utility/allocator.hpp b/include/pgduckdb/utility/allocator.hpp index 35a4bd8f..f4f75f17 100644 --- a/include/pgduckdb/utility/allocator.hpp +++ b/include/pgduckdb/utility/allocator.hpp @@ -26,7 +26,7 @@ struct DuckDBMallocator { } void - deallocate(T *p, std::size_t n) noexcept { + deallocate(T *p, std::size_t) noexcept { duckdb_free(p); } }; diff --git a/src/catalog/pgduckdb_catalog.cpp b/src/catalog/pgduckdb_catalog.cpp index 6d62af1d..b367617f 100644 --- a/src/catalog/pgduckdb_catalog.cpp +++ b/src/catalog/pgduckdb_catalog.cpp @@ -9,24 +9,21 @@ namespace pgduckdb { -PostgresCatalog::PostgresCatalog(duckdb::AttachedDatabase &db, const duckdb::string &connection_string, - duckdb::AccessMode access_mode) - : Catalog(db), path(connection_string), access_mode(access_mode) { +PostgresCatalog::PostgresCatalog(duckdb::AttachedDatabase &_db, const duckdb::string &connection_string, + duckdb::AccessMode _access_mode) + : Catalog(_db), path(connection_string), access_mode(_access_mode) { } duckdb::unique_ptr -PostgresCatalog::Attach(duckdb::StorageExtensionInfo *storage_info_p, duckdb::ClientContext &context, - duckdb::AttachedDatabase &db, const duckdb::string &name, duckdb::AttachInfo &info, - duckdb::AccessMode access_mode) { - auto connection_string = info.path; - return duckdb::make_uniq(db, connection_string, access_mode); +PostgresCatalog::Attach(duckdb::StorageExtensionInfo *, duckdb::ClientContext &, duckdb::AttachedDatabase &db, + const duckdb::string &, duckdb::AttachInfo &info, duckdb::AccessMode access_mode) { + return duckdb::make_uniq(db, info.path, access_mode); } // ------------------ Catalog API --------------------- void -PostgresCatalog::Initialize(bool load_builtin) { - return; +PostgresCatalog::Initialize(bool /*load_builtin*/) { } duckdb::string @@ -35,14 +32,14 @@ PostgresCatalog::GetCatalogType() { } duckdb::optional_ptr -PostgresCatalog::CreateSchema(duckdb::CatalogTransaction transaction, duckdb::CreateSchemaInfo &info) { +PostgresCatalog::CreateSchema(duckdb::CatalogTransaction, duckdb::CreateSchemaInfo &) { throw duckdb::NotImplementedException("CreateSchema not supported yet"); } duckdb::optional_ptr -PostgresCatalog::GetSchema(duckdb::CatalogTransaction transaction, const duckdb::string &schema_name, - duckdb::OnEntryNotFound if_not_found, duckdb::QueryErrorContext error_context) { - auto &pg_transaction = transaction.transaction->Cast(); +PostgresCatalog::GetSchema(duckdb::CatalogTransaction catalog_transaction, const duckdb::string &schema_name, + duckdb::OnEntryNotFound, duckdb::QueryErrorContext) { + auto &pg_transaction = catalog_transaction.transaction->Cast(); auto res = pg_transaction.GetCatalogEntry(duckdb::CatalogType::SCHEMA_ENTRY, schema_name, ""); D_ASSERT(res); D_ASSERT(res->type == duckdb::CatalogType::SCHEMA_ENTRY); @@ -50,43 +47,41 @@ PostgresCatalog::GetSchema(duckdb::CatalogTransaction transaction, const duckdb: } void -PostgresCatalog::ScanSchemas(duckdb::ClientContext &context, - std::function callback) { - return; +PostgresCatalog::ScanSchemas(duckdb::ClientContext &, std::function) { } duckdb::unique_ptr -PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &context, duckdb::LogicalCreateTable &op, - duckdb::unique_ptr plan) { +PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &, duckdb::LogicalCreateTable &, + duckdb::unique_ptr) { throw duckdb::NotImplementedException("PlanCreateTableAs not supported yet"); } duckdb::unique_ptr -PostgresCatalog::PlanInsert(duckdb::ClientContext &context, duckdb::LogicalInsert &op, - duckdb::unique_ptr plan) { +PostgresCatalog::PlanInsert(duckdb::ClientContext &, duckdb::LogicalInsert &, + duckdb::unique_ptr) { throw duckdb::NotImplementedException("PlanInsert not supported yet"); } duckdb::unique_ptr -PostgresCatalog::PlanDelete(duckdb::ClientContext &context, duckdb::LogicalDelete &op, - duckdb::unique_ptr plan) { +PostgresCatalog::PlanDelete(duckdb::ClientContext &, duckdb::LogicalDelete &, + duckdb::unique_ptr) { throw duckdb::NotImplementedException("PlanDelete not supported yet"); } duckdb::unique_ptr -PostgresCatalog::PlanUpdate(duckdb::ClientContext &context, duckdb::LogicalUpdate &op, - duckdb::unique_ptr plan) { +PostgresCatalog::PlanUpdate(duckdb::ClientContext &, duckdb::LogicalUpdate &, + duckdb::unique_ptr) { throw duckdb::NotImplementedException("PlanUpdate not supported yet"); } duckdb::unique_ptr -PostgresCatalog::BindCreateIndex(duckdb::Binder &binder, duckdb::CreateStatement &stmt, - duckdb::TableCatalogEntry &table, duckdb::unique_ptr plan) { +PostgresCatalog::BindCreateIndex(duckdb::Binder &, duckdb::CreateStatement &, duckdb::TableCatalogEntry &, + duckdb::unique_ptr) { throw duckdb::NotImplementedException("BindCreateIndex not supported yet"); } duckdb::DatabaseSize -PostgresCatalog::GetDatabaseSize(duckdb::ClientContext &context) { +PostgresCatalog::GetDatabaseSize(duckdb::ClientContext &) { throw duckdb::NotImplementedException("GetDatabaseSize not supported yet"); } @@ -101,7 +96,7 @@ PostgresCatalog::GetDBPath() { } void -PostgresCatalog::DropSchema(duckdb::ClientContext &context, duckdb::DropInfo &info) { +PostgresCatalog::DropSchema(duckdb::ClientContext &, duckdb::DropInfo &) { throw duckdb::NotImplementedException("DropSchema not supported yet"); } diff --git a/src/catalog/pgduckdb_schema.cpp b/src/catalog/pgduckdb_schema.cpp index 126cb708..3458aa43 100644 --- a/src/catalog/pgduckdb_schema.cpp +++ b/src/catalog/pgduckdb_schema.cpp @@ -7,86 +7,83 @@ namespace pgduckdb { -PostgresSchema::PostgresSchema(duckdb::Catalog &catalog, duckdb::CreateSchemaInfo &info, Snapshot snapshot) - : SchemaCatalogEntry(catalog, info), snapshot(snapshot), catalog(catalog) { +PostgresSchema::PostgresSchema(duckdb::Catalog &_catalog, duckdb::CreateSchemaInfo &_info, Snapshot _snapshot) + : SchemaCatalogEntry(_catalog, _info), snapshot(_snapshot), catalog(_catalog) { } void -PostgresSchema::Scan(duckdb::ClientContext &context, duckdb::CatalogType type, - const std::function &callback) { - return; +PostgresSchema::Scan(duckdb::ClientContext &, duckdb::CatalogType, const std::function &) { } void -PostgresSchema::Scan(duckdb::CatalogType type, const std::function &callback) { +PostgresSchema::Scan(duckdb::CatalogType, const std::function &) { throw duckdb::NotImplementedException("Scan(no context) not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateIndex(duckdb::CatalogTransaction transaction, duckdb::CreateIndexInfo &info, - duckdb::TableCatalogEntry &table) { +PostgresSchema::CreateIndex(duckdb::CatalogTransaction, duckdb::CreateIndexInfo &, duckdb::TableCatalogEntry &) { throw duckdb::NotImplementedException("CreateIndex not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateFunction(duckdb::CatalogTransaction transaction, duckdb::CreateFunctionInfo &info) { +PostgresSchema::CreateFunction(duckdb::CatalogTransaction, duckdb::CreateFunctionInfo &) { throw duckdb::NotImplementedException("CreateFunction not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateTable(duckdb::CatalogTransaction transaction, duckdb::BoundCreateTableInfo &info) { +PostgresSchema::CreateTable(duckdb::CatalogTransaction, duckdb::BoundCreateTableInfo &) { throw duckdb::NotImplementedException("CreateTable not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateView(duckdb::CatalogTransaction transaction, duckdb::CreateViewInfo &info) { +PostgresSchema::CreateView(duckdb::CatalogTransaction, duckdb::CreateViewInfo &) { throw duckdb::NotImplementedException("CreateView not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateSequence(duckdb::CatalogTransaction transaction, duckdb::CreateSequenceInfo &info) { +PostgresSchema::CreateSequence(duckdb::CatalogTransaction, duckdb::CreateSequenceInfo &) { throw duckdb::NotImplementedException("CreateSequence not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateTableFunction(duckdb::CatalogTransaction transaction, duckdb::CreateTableFunctionInfo &info) { +PostgresSchema::CreateTableFunction(duckdb::CatalogTransaction, duckdb::CreateTableFunctionInfo &) { throw duckdb::NotImplementedException("CreateTableFunction not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateCopyFunction(duckdb::CatalogTransaction transaction, duckdb::CreateCopyFunctionInfo &info) { +PostgresSchema::CreateCopyFunction(duckdb::CatalogTransaction, duckdb::CreateCopyFunctionInfo &) { throw duckdb::NotImplementedException("CreateCopyFunction not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreatePragmaFunction(duckdb::CatalogTransaction transaction, duckdb::CreatePragmaFunctionInfo &info) { +PostgresSchema::CreatePragmaFunction(duckdb::CatalogTransaction, duckdb::CreatePragmaFunctionInfo &) { throw duckdb::NotImplementedException("CreatePragmaFunction not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateCollation(duckdb::CatalogTransaction transaction, duckdb::CreateCollationInfo &info) { +PostgresSchema::CreateCollation(duckdb::CatalogTransaction, duckdb::CreateCollationInfo &) { throw duckdb::NotImplementedException("CreateCollation not supported yet"); } duckdb::optional_ptr -PostgresSchema::CreateType(duckdb::CatalogTransaction transaction, duckdb::CreateTypeInfo &info) { +PostgresSchema::CreateType(duckdb::CatalogTransaction, duckdb::CreateTypeInfo &) { throw duckdb::NotImplementedException("CreateType not supported yet"); } duckdb::optional_ptr -PostgresSchema::GetEntry(duckdb::CatalogTransaction transaction, duckdb::CatalogType type, - const duckdb::string &entry_name) { - auto &pg_transaction = transaction.transaction->Cast(); - return pg_transaction.GetCatalogEntry(type, name, entry_name); +PostgresSchema::GetEntry(duckdb::CatalogTransaction _catalog_transaction, duckdb::CatalogType _type, + const duckdb::string &_entry_name) { + auto &pg_transaction = _catalog_transaction.transaction->Cast(); + return pg_transaction.GetCatalogEntry(_type, name, _entry_name); } void -PostgresSchema::DropEntry(duckdb::ClientContext &context, duckdb::DropInfo &info) { +PostgresSchema::DropEntry(duckdb::ClientContext &, duckdb::DropInfo &) { throw duckdb::NotImplementedException("DropEntry not supported yet"); } void -PostgresSchema::Alter(duckdb::CatalogTransaction transaction, duckdb::AlterInfo &info) { +PostgresSchema::Alter(duckdb::CatalogTransaction, duckdb::AlterInfo &) { throw duckdb::NotImplementedException("Alter not supported yet"); } diff --git a/src/catalog/pgduckdb_storage.cpp b/src/catalog/pgduckdb_storage.cpp index d3e1d982..2362f178 100644 --- a/src/catalog/pgduckdb_storage.cpp +++ b/src/catalog/pgduckdb_storage.cpp @@ -7,8 +7,7 @@ namespace pgduckdb { static duckdb::unique_ptr -CreateTransactionManager(duckdb::StorageExtensionInfo *storage_info, duckdb::AttachedDatabase &db, - duckdb::Catalog &catalog) { +CreateTransactionManager(duckdb::StorageExtensionInfo *, duckdb::AttachedDatabase &db, duckdb::Catalog &catalog) { return duckdb::make_uniq(db, catalog.Cast()); } diff --git a/src/catalog/pgduckdb_table.cpp b/src/catalog/pgduckdb_table.cpp index 1a3af005..555adda6 100644 --- a/src/catalog/pgduckdb_table.cpp +++ b/src/catalog/pgduckdb_table.cpp @@ -13,9 +13,10 @@ namespace pgduckdb { -PostgresTable::PostgresTable(duckdb::Catalog &catalog, duckdb::SchemaCatalogEntry &schema, - duckdb::CreateTableInfo &info, Relation rel, Cardinality cardinality, Snapshot snapshot) - : duckdb::TableCatalogEntry(catalog, schema, info), rel(rel), cardinality(cardinality), snapshot(snapshot) { +PostgresTable::PostgresTable(duckdb::Catalog &_catalog, duckdb::SchemaCatalogEntry &_schema, + duckdb::CreateTableInfo &_info, Relation _rel, Cardinality _cardinality, + Snapshot _snapshot) + : duckdb::TableCatalogEntry(_catalog, _schema, _info), rel(_rel), cardinality(_cardinality), snapshot(_snapshot) { } PostgresTable::~PostgresTable() { @@ -58,26 +59,25 @@ PostgresTable::GetTableCardinality(Relation rel) { // PostgresHeapTable //===--------------------------------------------------------------------===// -PostgresHeapTable::PostgresHeapTable(duckdb::Catalog &catalog, duckdb::SchemaCatalogEntry &schema, - duckdb::CreateTableInfo &info, Relation rel, Cardinality cardinality, - Snapshot snapshot) - : PostgresTable(catalog, schema, info, rel, cardinality, snapshot) { +PostgresHeapTable::PostgresHeapTable(duckdb::Catalog &_catalog, duckdb::SchemaCatalogEntry &_schema, + duckdb::CreateTableInfo &_info, Relation _rel, Cardinality _cardinality, + Snapshot _snapshot) + : PostgresTable(_catalog, _schema, _info, _rel, _cardinality, _snapshot) { } duckdb::unique_ptr -PostgresHeapTable::GetStatistics(duckdb::ClientContext &context, duckdb::column_t column_id) { +PostgresHeapTable::GetStatistics(duckdb::ClientContext &, duckdb::column_t) { throw duckdb::NotImplementedException("GetStatistics not supported yet"); } duckdb::TableFunction -PostgresHeapTable::GetScanFunction(duckdb::ClientContext &context, - duckdb::unique_ptr &bind_data) { +PostgresHeapTable::GetScanFunction(duckdb::ClientContext &, duckdb::unique_ptr &bind_data) { bind_data = duckdb::make_uniq(rel, cardinality, snapshot); return PostgresSeqScanFunction(); } duckdb::TableStorageInfo -PostgresHeapTable::GetStorageInfo(duckdb::ClientContext &context) { +PostgresHeapTable::GetStorageInfo(duckdb::ClientContext &) { throw duckdb::NotImplementedException("GetStorageInfo not supported yet"); } diff --git a/src/catalog/pgduckdb_transaction.cpp b/src/catalog/pgduckdb_transaction.cpp index cf9de9aa..b79b8f65 100644 --- a/src/catalog/pgduckdb_transaction.cpp +++ b/src/catalog/pgduckdb_transaction.cpp @@ -19,16 +19,16 @@ ClosePostgresRelations(duckdb::ClientContext &context) { context_state->QueryEnd(); } -PostgresTransaction::PostgresTransaction(duckdb::TransactionManager &manager, duckdb::ClientContext &context, - PostgresCatalog &catalog, Snapshot snapshot) - : duckdb::Transaction(manager, context), catalog(catalog), snapshot(snapshot) { +PostgresTransaction::PostgresTransaction(duckdb::TransactionManager &_manager, duckdb::ClientContext &_context, + PostgresCatalog &_catalog, Snapshot _snapshot) + : duckdb::Transaction(_manager, _context), catalog(_catalog), snapshot(_snapshot) { } PostgresTransaction::~PostgresTransaction() { } -SchemaItems::SchemaItems(duckdb::unique_ptr &&schema, const duckdb::string &name) - : name(name), schema(std::move(schema)) { +SchemaItems::SchemaItems(duckdb::unique_ptr &&_schema, const duckdb::string &_name) + : name(_name), schema(std::move(_schema)) { } duckdb::optional_ptr diff --git a/src/catalog/pgduckdb_transaction_manager.cpp b/src/catalog/pgduckdb_transaction_manager.cpp index 9317f991..b10438ba 100644 --- a/src/catalog/pgduckdb_transaction_manager.cpp +++ b/src/catalog/pgduckdb_transaction_manager.cpp @@ -10,8 +10,8 @@ namespace pgduckdb { -PostgresTransactionManager::PostgresTransactionManager(duckdb::AttachedDatabase &db_p, PostgresCatalog &catalog) - : TransactionManager(db_p), catalog(catalog) { +PostgresTransactionManager::PostgresTransactionManager(duckdb::AttachedDatabase &_db_p, PostgresCatalog &_catalog) + : TransactionManager(_db_p), catalog(_catalog) { } duckdb::Transaction & @@ -42,8 +42,7 @@ PostgresTransactionManager::RollbackTransaction(duckdb::Transaction &transaction } void -PostgresTransactionManager::Checkpoint(duckdb::ClientContext &context, bool force) { - return; +PostgresTransactionManager::Checkpoint(duckdb::ClientContext &, bool /*force*/) { } } // namespace pgduckdb diff --git a/src/pgduckdb_background_worker.cpp b/src/pgduckdb_background_worker.cpp index 6f9a6631..042d84df 100644 --- a/src/pgduckdb_background_worker.cpp +++ b/src/pgduckdb_background_worker.cpp @@ -58,7 +58,7 @@ static uint64 initial_cache_version = 0; extern "C" { PGDLLEXPORT void -pgduckdb_background_worker_main(Datum main_arg) { +pgduckdb_background_worker_main(Datum /* main_arg */) { elog(LOG, "started pg_duckdb background worker"); // Set up a signal handler for SIGTERM pqsignal(SIGTERM, die); @@ -98,7 +98,7 @@ pgduckdb_background_worker_main(Datum main_arg) { ResetLatch(MyLatch); } - proc_exit(0); + // Unreachable } PG_FUNCTION_INFO_V1(force_motherduck_sync); @@ -525,10 +525,12 @@ CreateSchemaIfNotExists(const char *postgres_schema_name, bool is_default_db) { ObjectAddress schema_address = { .classId = NamespaceRelationId, .objectId = schema_oid, + .objectSubId = 0, }; ObjectAddress extension_address = { .classId = ExtensionRelationId, .objectId = pgduckdb::ExtensionOid(), + .objectSubId = 0, }; recordDependencyOn(&schema_address, &extension_address, DEPENDENCY_NORMAL); } diff --git a/src/pgduckdb_ddl.cpp b/src/pgduckdb_ddl.cpp index 610a2896..89de5adc 100644 --- a/src/pgduckdb_ddl.cpp +++ b/src/pgduckdb_ddl.cpp @@ -51,7 +51,7 @@ DuckdbTruncateTable(Oid relation_oid) { } void -DuckdbHandleDDL(Node *parsetree, const char *queryString) { +DuckdbHandleDDL(Node *parsetree) { if (!pgduckdb::IsExtensionRegistered()) { /* We're not installed, so don't mess with the query */ return; @@ -418,7 +418,7 @@ DECLARE_PG_FUNCTION(duckdb_drop_trigger) { * a new version. */ if (pgduckdb::IsMotherDuckEnabled() && !pgduckdb::doing_motherduck_sync) { - for (auto proc = 0; proc < SPI_processed; ++proc) { + for (uint64_t proc = 0; proc < SPI_processed; ++proc) { if (!connection) { /* * For now, we don't support DuckDB queries in transactions. To support @@ -453,7 +453,7 @@ DECLARE_PG_FUNCTION(duckdb_drop_trigger) { if (ret != SPI_OK_SELECT) elog(ERROR, "SPI_exec failed: error code %s", SPI_result_code_string(ret)); - for (auto proc = 0; proc < SPI_processed; ++proc) { + for (uint64_t proc = 0; proc < SPI_processed; ++proc) { HeapTuple tuple = SPI_tuptable->vals[proc]; bool isnull; diff --git a/src/pgduckdb_detoast.cpp b/src/pgduckdb_detoast.cpp index 1fb98414..431441b4 100644 --- a/src/pgduckdb_detoast.cpp +++ b/src/pgduckdb_detoast.cpp @@ -110,7 +110,11 @@ ToastFetchDatum(struct varlena *attr) { struct varlena *result = (struct varlena *)duckdb_malloc(attrsize + VARHDRSZ); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored \ + "-Wsign-compare" // Ignore sign comparison warning that VARATT_EXTERNAL_IS_COMPRESSED generatess if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) { +#pragma GCC diagnostic pop SET_VARSIZE_COMPRESSED(result, attrsize + VARHDRSZ); } else { SET_VARSIZE(result, attrsize + VARHDRSZ); diff --git a/src/pgduckdb_hooks.cpp b/src/pgduckdb_hooks.cpp index 6275b411..bc643468 100644 --- a/src/pgduckdb_hooks.cpp +++ b/src/pgduckdb_hooks.cpp @@ -240,7 +240,7 @@ DuckdbUtilityHook_Cpp(PlannedStmt *pstmt, const char *query_string, bool read_on } if (pgduckdb::IsExtensionRegistered()) { - DuckdbHandleDDL(parsetree, query_string); + DuckdbHandleDDL(parsetree); } if (prev_process_utility_hook) { diff --git a/src/pgduckdb_metadata_cache.cpp b/src/pgduckdb_metadata_cache.cpp index 2b8af1e4..339406f8 100644 --- a/src/pgduckdb_metadata_cache.cpp +++ b/src/pgduckdb_metadata_cache.cpp @@ -75,7 +75,7 @@ uint32 schema_hash_value; * IsExtensionRegistered for details). */ static void -InvalidateCaches(Datum arg, int cache_id, uint32 hash_value) { +InvalidateCaches(Datum /*arg*/, int /*cache_id*/, uint32 hash_value) { if (hash_value != schema_hash_value) { return; } @@ -112,7 +112,7 @@ BuildDuckdbOnlyFunctions() { const char *function_names[] = {"read_parquet", "read_csv", "iceberg_scan", "iceberg_metadata", "iceberg_snapshots", "delta_scan", "read_json"}; - for (int i = 0; i < lengthof(function_names); i++) { + for (uint32_t i = 0; i < lengthof(function_names); i++) { CatCList *catlist = SearchSysCacheList1(PROCNAMEARGSNSP, CStringGetDatum(function_names[i])); for (int j = 0; j < catlist->n_members; j++) { diff --git a/src/pgduckdb_node.cpp b/src/pgduckdb_node.cpp index 2ebad7e7..c05ff3eb 100644 --- a/src/pgduckdb_node.cpp +++ b/src/pgduckdb_node.cpp @@ -71,7 +71,7 @@ Duckdb_CreateCustomScanState(CustomScan *cscan) { } void -Duckdb_BeginCustomScan_Cpp(CustomScanState *cscanstate, EState *estate, int eflags) { +Duckdb_BeginCustomScan_Cpp(CustomScanState *cscanstate, EState *estate, int /*eflags*/) { DuckdbScanState *duckdb_scan_state = (DuckdbScanState *)cscanstate; duckdb::unique_ptr prepared_query = DuckdbPrepare(duckdb_scan_state->query); @@ -226,11 +226,11 @@ Duckdb_EndCustomScan(CustomScanState *node) { } void -Duckdb_ReScanCustomScan(CustomScanState *node) { +Duckdb_ReScanCustomScan(CustomScanState * /*node*/) { } void -Duckdb_ExplainCustomScan_Cpp(CustomScanState *node, List *ancestors, ExplainState *es) { +Duckdb_ExplainCustomScan_Cpp(CustomScanState *node, ExplainState *es) { DuckdbScanState *duckdb_scan_state = (DuckdbScanState *)node; ExecuteQuery(duckdb_scan_state); @@ -254,8 +254,8 @@ Duckdb_ExplainCustomScan_Cpp(CustomScanState *node, List *ancestors, ExplainStat } void -Duckdb_ExplainCustomScan(CustomScanState *node, List *ancestors, ExplainState *es) { - InvokeCPPFunc(Duckdb_ExplainCustomScan_Cpp, node, ancestors, es); +Duckdb_ExplainCustomScan(CustomScanState *node, List * /*ancestors*/, ExplainState *es) { + InvokeCPPFunc(Duckdb_ExplainCustomScan_Cpp, node, es); } extern "C" void diff --git a/src/pgduckdb_planner.cpp b/src/pgduckdb_planner.cpp index 0f463b39..670b284a 100644 --- a/src/pgduckdb_planner.cpp +++ b/src/pgduckdb_planner.cpp @@ -50,8 +50,8 @@ DuckdbPrepare(const Query *query) { elog(DEBUG2, "(PGDuckDB/DuckdbPrepare) Preparing: %s", query_string); - auto duckdb_connection = pgduckdb::DuckDBManager::GetConnection(); - auto prepared_query = duckdb_connection->context->Prepare(query_string); + auto con = pgduckdb::DuckDBManager::GetConnection(); + auto prepared_query = con->context->Prepare(query_string); return prepared_query; } @@ -73,7 +73,7 @@ CreatePlan(Query *query, bool throw_error) { auto &prepared_result_types = prepared_query->GetTypes(); - for (auto i = 0; i < prepared_result_types.size(); i++) { + for (size_t i = 0; i < prepared_result_types.size(); i++) { auto &column = prepared_result_types[i]; Oid postgresColumnOid = pgduckdb::GetPostgresDuckDBType(column); diff --git a/src/pgduckdb_table_am.cpp b/src/pgduckdb_table_am.cpp index a068b320..048716d7 100644 --- a/src/pgduckdb_table_am.cpp +++ b/src/pgduckdb_table_am.cpp @@ -39,7 +39,7 @@ PG_FUNCTION_INFO_V1(duckdb_am_handler); */ static const TupleTableSlotOps * -duckdb_slot_callbacks(Relation relation) { +duckdb_slot_callbacks(Relation /*relation*/) { /* * Here we would most likely want to invent your own set of slot * callbacks for our AM. For now we just use the minimal tuple slot, we @@ -61,7 +61,7 @@ typedef struct DuckdbScanDescData { typedef struct DuckdbScanDescData *DuckdbScanDesc; static TableScanDesc -duckdb_scan_begin(Relation relation, Snapshot snapshot, int nkeys, ScanKey key, ParallelTableScanDesc parallel_scan, +duckdb_scan_begin(Relation relation, Snapshot snapshot, int nkeys, ScanKey /*key*/, ParallelTableScanDesc parallel_scan, uint32 flags) { DuckdbScanDesc scan = (DuckdbScanDesc)palloc(sizeof(DuckdbScanDescData)); @@ -82,13 +82,13 @@ duckdb_scan_end(TableScanDesc sscan) { } static void -duckdb_scan_rescan(TableScanDesc sscan, ScanKey key, bool set_params, bool allow_strat, bool allow_sync, - bool allow_pagemode) { +duckdb_scan_rescan(TableScanDesc /*sscan*/, ScanKey /*key*/, bool /*set_params*/, bool /*allow_strat*/, + bool /*allow_sync*/, bool /*allow_pagemode*/) { NOT_IMPLEMENTED(); } static bool -duckdb_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot) { +duckdb_scan_getnextslot(TableScanDesc /*sscan*/, ScanDirection /*direction*/, TupleTableSlot * /*slot*/) { NOT_IMPLEMENTED(); } @@ -98,23 +98,23 @@ duckdb_scan_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTable */ static IndexFetchTableData * -duckdb_index_fetch_begin(Relation rel) { +duckdb_index_fetch_begin(Relation /*rel*/) { NOT_IMPLEMENTED(); } static void -duckdb_index_fetch_reset(IndexFetchTableData *scan) { +duckdb_index_fetch_reset(IndexFetchTableData * /*scan*/) { NOT_IMPLEMENTED(); } static void -duckdb_index_fetch_end(IndexFetchTableData *scan) { +duckdb_index_fetch_end(IndexFetchTableData * /*scan*/) { NOT_IMPLEMENTED(); } static bool -duckdb_index_fetch_tuple(struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, - bool *call_again, bool *all_dead) { +duckdb_index_fetch_tuple(struct IndexFetchTableData * /*scan*/, ItemPointer /*tid*/, Snapshot /*snapshot*/, + TupleTableSlot * /*slot*/, bool * /*call_again*/, bool * /*all_dead*/) { NOT_IMPLEMENTED(); } @@ -125,27 +125,27 @@ duckdb_index_fetch_tuple(struct IndexFetchTableData *scan, ItemPointer tid, Snap */ static bool -duckdb_fetch_row_version(Relation relation, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot) { +duckdb_fetch_row_version(Relation /*relation*/, ItemPointer /*tid*/, Snapshot /*snapshot*/, TupleTableSlot * /*slot*/) { NOT_IMPLEMENTED(); } static void -duckdb_get_latest_tid(TableScanDesc sscan, ItemPointer tid) { +duckdb_get_latest_tid(TableScanDesc /*sscan*/, ItemPointer /*tid*/) { NOT_IMPLEMENTED(); } static bool -duckdb_tuple_tid_valid(TableScanDesc scan, ItemPointer tid) { +duckdb_tuple_tid_valid(TableScanDesc /*scan*/, ItemPointer /*tid*/) { NOT_IMPLEMENTED(); } static bool -duckdb_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot, Snapshot snapshot) { +duckdb_tuple_satisfies_snapshot(Relation /*rel*/, TupleTableSlot * /*slot*/, Snapshot /*snapshot*/) { NOT_IMPLEMENTED(); } static TransactionId -duckdb_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate) { +duckdb_index_delete_tuples(Relation /*rel*/, TM_IndexDeleteOp * /*delstate*/) { NOT_IMPLEMENTED(); } @@ -155,61 +155,64 @@ duckdb_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate) { */ static void -duckdb_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid, int options, BulkInsertState bistate) { +duckdb_tuple_insert(Relation /*relation*/, TupleTableSlot * /*slot*/, CommandId /*cid*/, int /*options*/, + BulkInsertState /*bistate*/) { NOT_IMPLEMENTED(); } static void -duckdb_tuple_insert_speculative(Relation relation, TupleTableSlot *slot, CommandId cid, int options, - BulkInsertState bistate, uint32 specToken) { +duckdb_tuple_insert_speculative(Relation /*relation*/, TupleTableSlot * /*slot*/, CommandId /*cid*/, int /*options*/, + BulkInsertState /*bistate*/, uint32 /*specToken*/) { NOT_IMPLEMENTED(); } static void -duckdb_tuple_complete_speculative(Relation relation, TupleTableSlot *slot, uint32 spekToken, bool succeeded) { +duckdb_tuple_complete_speculative(Relation /*relation*/, TupleTableSlot * /*slot*/, uint32 /*spekToken*/, + bool /*succeeded*/) { NOT_IMPLEMENTED(); } static void -duckdb_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, CommandId cid, int options, - BulkInsertState bistate) { +duckdb_multi_insert(Relation /*relation*/, TupleTableSlot ** /*slots*/, int /*ntuples*/, CommandId /*cid*/, + int /*options*/, BulkInsertState /*bistate*/) { NOT_IMPLEMENTED(); } static TM_Result -duckdb_tuple_delete(Relation relation, ItemPointer tid, CommandId cid, Snapshot snapshot, Snapshot crosscheck, - bool wait, TM_FailureData *tmfd, bool changingPart) { +duckdb_tuple_delete(Relation /*relation*/, ItemPointer /*tid*/, CommandId /*cid*/, Snapshot /*snapshot*/, + Snapshot /*crosscheck*/, bool /*wait*/, TM_FailureData * /*tmfd*/, bool /*changingPart*/) { NOT_IMPLEMENTED(); } #if PG_VERSION_NUM >= 160000 static TM_Result -duckdb_tuple_update(Relation relation, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, - Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, - TU_UpdateIndexes *update_indexes) { +duckdb_tuple_update(Relation /*relation*/, ItemPointer /*otid*/, TupleTableSlot * /*slot*/, CommandId /*cid*/, + Snapshot /*snapshot*/, Snapshot /*crosscheck*/, bool /*wait*/, TM_FailureData * /*tmfd*/, + LockTupleMode * /*lockmode*/, TU_UpdateIndexes * /*update_indexes*/) { NOT_IMPLEMENTED(); } #else static TM_Result -duckdb_tuple_update(Relation rel, ItemPointer otid, TupleTableSlot *slot, CommandId cid, Snapshot snapshot, - Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, - bool *update_indexes) { +duckdb_tuple_update(Relation /*rel*/, ItemPointer /*otid*/, TupleTableSlot * /*slot*/, CommandId /*cid*/, + Snapshot /*snapshot*/, Snapshot /*crosscheck*/, bool /*wait*/, TM_FailureData * /*tmfd*/, + LockTupleMode * /*lockmode*/, bool * /*update_indexes*/) { NOT_IMPLEMENTED(); } #endif static TM_Result -duckdb_tuple_lock(Relation relation, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, CommandId cid, - LockTupleMode mode, LockWaitPolicy wait_policy, uint8 flags, TM_FailureData *tmfd) { +duckdb_tuple_lock(Relation /*relation*/, ItemPointer /*tid*/, Snapshot /*snapshot*/, TupleTableSlot * /*slot*/, + CommandId /*cid*/, LockTupleMode /*mode*/, LockWaitPolicy /*wait_policy*/, uint8 /*flags*/, + TM_FailureData * /*tmfd*/) { NOT_IMPLEMENTED(); } static void -duckdb_finish_bulk_insert(Relation relation, int options) { +duckdb_finish_bulk_insert(Relation /*relation*/, int /*options*/) { NOT_IMPLEMENTED(); } @@ -221,8 +224,8 @@ duckdb_finish_bulk_insert(Relation relation, int options) { #if PG_VERSION_NUM >= 160000 static void -duckdb_relation_set_new_filelocator(Relation rel, const RelFileLocator *newrnode, char persistence, - TransactionId *freezeXid, MultiXactId *minmulti) { +duckdb_relation_set_new_filelocator(Relation rel, const RelFileLocator * /*newrnode*/, char /*persistence*/, + TransactionId * /*freezeXid*/, MultiXactId * /*minmulti*/) { HeapTuple tp = SearchSysCache1(RELOID, ObjectIdGetDatum(rel->rd_id)); if (!HeapTupleIsValid(tp)) { /* nothing to do, the table will be created in DuckDB later by the @@ -236,8 +239,8 @@ duckdb_relation_set_new_filelocator(Relation rel, const RelFileLocator *newrnode #else static void -duckdb_relation_set_new_filenode(Relation rel, const RelFileNode *newrnode, char persistence, TransactionId *freezeXid, - MultiXactId *minmulti) { +duckdb_relation_set_new_filenode(Relation rel, const RelFileNode * /*newrnode*/, char /*persistence*/, + TransactionId * /*freezeXid*/, MultiXactId * /*minmulti*/) { HeapTuple tp = SearchSysCache1(RELOID, ObjectIdGetDatum(rel->rd_id)); if (!HeapTupleIsValid(tp)) { /* nothing to do, the table will be created in DuckDB later by the @@ -258,35 +261,35 @@ duckdb_relation_nontransactional_truncate(Relation rel) { #if PG_VERSION_NUM >= 160000 static void -duckdb_copy_data(Relation rel, const RelFileLocator *newrnode) { +duckdb_copy_data(Relation /*rel*/, const RelFileLocator * /*newrnode*/) { NOT_IMPLEMENTED(); } #else static void -duckdb_copy_data(Relation rel, const RelFileNode *newrnode) { +duckdb_copy_data(Relation /*rel*/, const RelFileNode * /*newrnode*/) { NOT_IMPLEMENTED(); } #endif static void -duckdb_copy_for_cluster(Relation OldTable, Relation NewTable, Relation OldIndex, bool use_sort, - TransactionId OldestXmin, TransactionId *xid_cutoff, MultiXactId *multi_cutoff, - double *num_tuples, double *tups_vacuumed, double *tups_recently_dead) { +duckdb_copy_for_cluster(Relation /*OldTable*/, Relation /*NewTable*/, Relation /*OldIndex*/, bool /*use_sort*/, + TransactionId /*OldestXmin*/, TransactionId * /*xid_cutoff*/, MultiXactId * /*multi_cutoff*/, + double * /*num_tuples*/, double * /*tups_vacuumed*/, double * /*tups_recently_dead*/) { NOT_IMPLEMENTED(); } static void -duckdb_vacuum(Relation onerel, VacuumParams *params, BufferAccessStrategy bstrategy) { +duckdb_vacuum(Relation /*onerel*/, VacuumParams * /*params*/, BufferAccessStrategy /*bstrategy*/) { NOT_IMPLEMENTED(); } #if PG_VERSION_NUM >= 170000 static bool -duckdb_scan_analyze_next_block(TableScanDesc scan, ReadStream *stream) { +duckdb_scan_analyze_next_block(TableScanDesc /*scan*/, ReadStream * /*stream*/) { /* no data in postgres, so no point to analyze next block */ return false; } @@ -294,28 +297,29 @@ duckdb_scan_analyze_next_block(TableScanDesc scan, ReadStream *stream) { #else static bool -duckdb_scan_analyze_next_block(TableScanDesc scan, BlockNumber blockno, BufferAccessStrategy bstrategy) { +duckdb_scan_analyze_next_block(TableScanDesc /*scan*/, BlockNumber /*blockno*/, BufferAccessStrategy /*bstrategy*/) { /* no data in postgres, so no point to analyze next block */ return false; } #endif static bool -duckdb_scan_analyze_next_tuple(TableScanDesc scan, TransactionId OldestXmin, double *liverows, double *deadrows, - TupleTableSlot *slot) { +duckdb_scan_analyze_next_tuple(TableScanDesc /*scan*/, TransactionId /*OldestXmin*/, double * /*liverows*/, double * /*deadrows*/, + TupleTableSlot * /*slot*/) { NOT_IMPLEMENTED(); } static double -duckdb_index_build_range_scan(Relation tableRelation, Relation indexRelation, IndexInfo *indexInfo, bool allow_sync, - bool anyvisible, bool progress, BlockNumber start_blockno, BlockNumber numblocks, - IndexBuildCallback callback, void *callback_state, TableScanDesc scan) { +duckdb_index_build_range_scan(Relation /*tableRelation*/, Relation /*indexRelation*/, IndexInfo * /*indexInfo*/, + bool /*allow_sync*/, bool /*anyvisible*/, bool /*progress*/, + BlockNumber /*start_blockno*/, BlockNumber /*numblocks*/, IndexBuildCallback /*callback*/, + void * /*callback_state*/, TableScanDesc /*scan*/) { NOT_IMPLEMENTED(); } static void -duckdb_index_validate_scan(Relation tableRelation, Relation indexRelation, IndexInfo *indexInfo, Snapshot snapshot, - ValidateIndexState *state) { +duckdb_index_validate_scan(Relation /*tableRelation*/, Relation /*indexRelation*/, IndexInfo * /*indexInfo*/, + Snapshot /*snapshot*/, ValidateIndexState * /*state*/) { NOT_IMPLEMENTED(); } @@ -325,7 +329,7 @@ duckdb_index_validate_scan(Relation tableRelation, Relation indexRelation, Index */ static uint64 -duckdb_relation_size(Relation rel, ForkNumber forkNumber) { +duckdb_relation_size(Relation /*rel*/, ForkNumber /*forkNumber*/) { /* * For now we just return 0. We should probably want return something more * useful in the future though. @@ -337,7 +341,7 @@ duckdb_relation_size(Relation rel, ForkNumber forkNumber) { * Check to see whether the table needs a TOAST table. */ static bool -duckdb_relation_needs_toast_table(Relation rel) { +duckdb_relation_needs_toast_table(Relation /*rel*/) { /* we don't need toast, because everything is stored in duckdb */ return false; @@ -349,7 +353,7 @@ duckdb_relation_needs_toast_table(Relation rel) { */ static void -duckdb_estimate_rel_size(Relation rel, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac) { +duckdb_estimate_rel_size(Relation /*rel*/, int32 *attr_widths, BlockNumber *pages, double *tuples, double *allvisfrac) { /* no data available */ if (attr_widths) *attr_widths = 0; @@ -367,22 +371,22 @@ duckdb_estimate_rel_size(Relation rel, int32 *attr_widths, BlockNumber *pages, d */ static bool -duckdb_scan_bitmap_next_block(TableScanDesc scan, TBMIterateResult *tbmres) { +duckdb_scan_bitmap_next_block(TableScanDesc /*scan*/, TBMIterateResult * /*tbmres*/) { NOT_IMPLEMENTED(); } static bool -duckdb_scan_bitmap_next_tuple(TableScanDesc scan, TBMIterateResult *tbmres, TupleTableSlot *slot) { +duckdb_scan_bitmap_next_tuple(TableScanDesc /*scan*/, TBMIterateResult * /*tbmres*/, TupleTableSlot * /*slot*/) { NOT_IMPLEMENTED(); } static bool -duckdb_scan_sample_next_block(TableScanDesc scan, SampleScanState *scanstate) { +duckdb_scan_sample_next_block(TableScanDesc /*scan*/, SampleScanState * /*scanstate*/) { NOT_IMPLEMENTED(); } static bool -duckdb_scan_sample_next_tuple(TableScanDesc scan, SampleScanState *scanstate, TupleTableSlot *slot) { +duckdb_scan_sample_next_tuple(TableScanDesc /*scan*/, SampleScanState * /*scanstate*/, TupleTableSlot * /*slot*/) { NOT_IMPLEMENTED(); } @@ -458,7 +462,7 @@ static const TableAmRoutine duckdb_methods = {.type = T_TableAmRoutine, .scan_sample_next_tuple = duckdb_scan_sample_next_tuple}; Datum -duckdb_am_handler(PG_FUNCTION_ARGS) { +duckdb_am_handler(FunctionCallInfo /*funcinfo*/) { PG_RETURN_POINTER(&duckdb_methods); } } diff --git a/src/pgduckdb_types.cpp b/src/pgduckdb_types.cpp index c36857d4..65b2a570 100644 --- a/src/pgduckdb_types.cpp +++ b/src/pgduckdb_types.cpp @@ -140,7 +140,7 @@ ConvertNumeric(T value, idx_t scale) { // count the amount of digits required for the fractional part // note that while it is technically possible to leave out zeros here this adds even more complications // so we just always write digits for the full "scale", even if not strictly required - int32_t fractional_ndigits = (scale + DEC_DIGITS - 1) / DEC_DIGITS; + idx_t fractional_ndigits = (scale + DEC_DIGITS - 1) / DEC_DIGITS; // fractional digits are LEFT aligned (for some unknown reason) // that means if we write ".12" with a scale of 2 we actually need to write "1200", instead of "12" // this means we need to "correct" the number 12 by multiplying by 100 in this case @@ -448,7 +448,7 @@ namespace { template struct PostgresArrayAppendState { public: - PostgresArrayAppendState(idx_t number_of_dimensions) : number_of_dimensions(number_of_dimensions) { + PostgresArrayAppendState(idx_t _number_of_dimensions) : number_of_dimensions(_number_of_dimensions) { dimensions = (int *)palloc(number_of_dimensions * sizeof(int)); lower_bounds = (int *)palloc(number_of_dimensions * sizeof(int)); for (idx_t i = 0; i < number_of_dimensions; i++) { @@ -466,7 +466,7 @@ struct PostgresArrayAppendState { AppendValueAtDimension(const duckdb::Value &value, idx_t dimension) { // FIXME: verify that the amount of values does not overflow an `int` ? auto &values = duckdb::ListValue::GetChildren(value); - idx_t to_append = values.size(); + int to_append = values.size(); D_ASSERT(dimension < number_of_dimensions); if (dimensions[dimension] == -1) { @@ -482,8 +482,7 @@ struct PostgresArrayAppendState { auto &child_type = duckdb::ListType::GetChildType(value.type()); if (child_type.id() == duckdb::LogicalTypeId::LIST) { - for (idx_t i = 0; i < to_append; i++) { - auto &child_val = values[i]; + for (auto &child_val : values) { if (child_val.IsNull()) { // Postgres arrays can not contains nulls at the array level // i.e {{1,2}, NULL, {3,4}} is not supported @@ -500,14 +499,13 @@ struct PostgresArrayAppendState { nulls = (bool *)palloc(expected_values * sizeof(bool)); } - for (idx_t i = 0; i < to_append; i++) { - auto &child_val = values[i]; - nulls[count + i] = child_val.IsNull(); - if (!nulls[count + i]) { - datums[count + i] = OP::ConvertToPostgres(values[i]); + for (auto &child_val : values) { + nulls[count] = child_val.IsNull(); + if (!nulls[count]) { + datums[count] = OP::ConvertToPostgres(child_val); } + ++count; } - count += to_append; } } @@ -949,7 +947,7 @@ ConvertDecimal(const NumericVar &numeric) { T integral_part = 0, fractional_part = 0; if (numeric.weight >= 0) { - idx_t digit_index = 0; + int32_t digit_index = 0; integral_part = numeric.digits[digit_index++]; for (; digit_index <= numeric.weight; digit_index++) { integral_part *= NBASE; diff --git a/src/pgduckdb_xact.cpp b/src/pgduckdb_xact.cpp index 03a95a6f..5ae5f44a 100644 --- a/src/pgduckdb_xact.cpp +++ b/src/pgduckdb_xact.cpp @@ -9,7 +9,7 @@ extern "C" { namespace pgduckdb { static void -DuckdbXactCallback_Cpp(XactEvent event, void *arg) { +DuckdbXactCallback_Cpp(XactEvent event, void *) { if (!started_duckdb_transaction) { return; } diff --git a/src/scan/postgres_scan.cpp b/src/scan/postgres_scan.cpp index db84adb7..151ff69f 100644 --- a/src/scan/postgres_scan.cpp +++ b/src/scan/postgres_scan.cpp @@ -146,8 +146,8 @@ ReplaceView(Oid view) { } duckdb::unique_ptr -PostgresReplacementScan(duckdb::ClientContext &context, duckdb::ReplacementScanInput &input, - duckdb::optional_ptr data) { +PostgresReplacementScan(duckdb::ClientContext &, duckdb::ReplacementScanInput &input, + duckdb::optional_ptr) { auto &schema_name = input.schema_name; auto &table_name = input.table_name; diff --git a/src/scan/postgres_seq_scan.cpp b/src/scan/postgres_seq_scan.cpp index 6b96faf6..d3fcc4e0 100644 --- a/src/scan/postgres_seq_scan.cpp +++ b/src/scan/postgres_seq_scan.cpp @@ -68,17 +68,15 @@ PostgresSeqScanFunction::PostgresSeqScanFunction() } duckdb::unique_ptr -PostgresSeqScanFunction::PostgresSeqScanInitGlobal(duckdb::ClientContext &context, - duckdb::TableFunctionInitInput &input) { +PostgresSeqScanFunction::PostgresSeqScanInitGlobal(duckdb::ClientContext &, duckdb::TableFunctionInitInput &input) { auto &bind_data = input.bind_data->CastNoConst(); auto global_state = duckdb::make_uniq(bind_data.m_rel, input); global_state->m_global_state->m_snapshot = bind_data.m_snapshot; - return std::move(global_state); + return global_state; } duckdb::unique_ptr -PostgresSeqScanFunction::PostgresSeqScanInitLocal(duckdb::ExecutionContext &context, - duckdb::TableFunctionInitInput &input, +PostgresSeqScanFunction::PostgresSeqScanInitLocal(duckdb::ExecutionContext &, duckdb::TableFunctionInitInput &, duckdb::GlobalTableFunctionState *gstate) { auto global_state = reinterpret_cast(gstate); return duckdb::make_uniq( @@ -86,7 +84,7 @@ PostgresSeqScanFunction::PostgresSeqScanInitLocal(duckdb::ExecutionContext &cont } void -PostgresSeqScanFunction::PostgresSeqScanFunc(duckdb::ClientContext &context, duckdb::TableFunctionInput &data, +PostgresSeqScanFunction::PostgresSeqScanFunc(duckdb::ClientContext &, duckdb::TableFunctionInput &data, duckdb::DataChunk &output) { auto &local_state = data.local_state->Cast(); @@ -106,7 +104,7 @@ PostgresSeqScanFunction::PostgresSeqScanFunc(duckdb::ClientContext &context, duc } duckdb::unique_ptr -PostgresSeqScanFunction::PostgresSeqScanCardinality(duckdb::ClientContext &context, const duckdb::FunctionData *data) { +PostgresSeqScanFunction::PostgresSeqScanCardinality(duckdb::ClientContext &, const duckdb::FunctionData *data) { auto &bind_data = data->Cast(); return duckdb::make_uniq(bind_data.m_cardinality, bind_data.m_cardinality); } diff --git a/src/vendor/pg_ruleutils_14.c b/src/vendor/pg_ruleutils_14.c index ebcf18f1..9b44f7db 100644 --- a/src/vendor/pg_ruleutils_14.c +++ b/src/vendor/pg_ruleutils_14.c @@ -13,6 +13,10 @@ #if PG_VERSION_NUM >= 140000 && PG_VERSION_NUM < 150000 +#pragma GCC diagnostic ignored "-Wshadow" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wsign-compare" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wunused-parameter" // ignore any compiler warnings + #include #include #include diff --git a/src/vendor/pg_ruleutils_15.c b/src/vendor/pg_ruleutils_15.c index 0c75341b..7d1815bb 100644 --- a/src/vendor/pg_ruleutils_15.c +++ b/src/vendor/pg_ruleutils_15.c @@ -13,6 +13,10 @@ #if PG_VERSION_NUM >= 150000 && PG_VERSION_NUM < 160000 +#pragma GCC diagnostic ignored "-Wshadow" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wsign-compare" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wunused-parameter" // ignore any compiler warnings + #include #include #include diff --git a/src/vendor/pg_ruleutils_16.c b/src/vendor/pg_ruleutils_16.c index d7843f69..a96e1509 100644 --- a/src/vendor/pg_ruleutils_16.c +++ b/src/vendor/pg_ruleutils_16.c @@ -13,6 +13,10 @@ #if PG_VERSION_NUM >= 160000 && PG_VERSION_NUM < 170000 +#pragma GCC diagnostic ignored "-Wshadow" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wsign-compare" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wunused-parameter" // ignore any compiler warnings + #include #include #include diff --git a/src/vendor/pg_ruleutils_17.c b/src/vendor/pg_ruleutils_17.c index 905a86e6..46e8fafe 100644 --- a/src/vendor/pg_ruleutils_17.c +++ b/src/vendor/pg_ruleutils_17.c @@ -13,6 +13,10 @@ #if PG_VERSION_NUM >= 170000 && PG_VERSION_NUM < 180000 +#pragma GCC diagnostic ignored "-Wshadow" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wsign-compare" // ignore any compiler warnings +#pragma GCC diagnostic ignored "-Wunused-parameter" // ignore any compiler warnings + #include #include #include