Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail compilation on warnings #439

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ 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}
override PG_CPPFLAGS += -Iinclude -isystem third_party/duckdb/src/include -isystem third_party/duckdb/third_party/re2
override PG_CXXFLAGS += -std=c++17 -Wno-sign-compare -Wno-register -Wshadow -Wswitch -Wunused-parameter -Wunreachable-code -Wno-unknown-pragmas ${DUCKDB_BUILD_CXX_FLAGS} -Wall -Wextra -Werror

SHLIB_LINK += -Wl,-rpath,$(PG_LIB)/ -lpq -Lthird_party/duckdb/build/$(DUCKDB_BUILD_TYPE)/src -L$(PG_LIB) -lduckdb -lstdc++ -llz4

Expand Down
2 changes: 1 addition & 1 deletion include/pgduckdb/scan/postgres_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class PostgresScanLocalState {
}
}

int m_output_vector_size;
uint32_t m_output_vector_size;
bool m_exhausted_scan;
std::vector<Datum, DuckDBMallocator<Datum>> values;
std::vector<bool, DuckDBMallocator<bool>> nulls;
Expand Down
4 changes: 2 additions & 2 deletions include/pgduckdb/types/decimal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ struct DecimalConversionInteger {

template <class T>
static T
Finalize(const NumericVar &numeric, T result) {
Finalize(const NumericVar &, T result) {
return result;
}
};
Expand Down Expand Up @@ -349,7 +349,7 @@ struct DecimalConversionHugeint {
}

static hugeint_t
Finalize(const NumericVar &numeric, hugeint_t result) {
Finalize(const NumericVar &, hugeint_t result) {
return result;
}
};
Expand Down
2 changes: 1 addition & 1 deletion include/pgduckdb/utility/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down
47 changes: 21 additions & 26 deletions src/catalog/pgduckdb_catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,15 @@ PostgresCatalog::PostgresCatalog(duckdb::AttachedDatabase &db, const duckdb::str
}

duckdb::unique_ptr<duckdb::Catalog>
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<PostgresCatalog>(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<PostgresCatalog>(db, info.path, access_mode);
}

// ------------------ Catalog API ---------------------

void
PostgresCatalog::Initialize(bool load_builtin) {
return;
PostgresCatalog::Initialize(bool) {
}

duckdb::string
Expand All @@ -35,58 +32,56 @@ PostgresCatalog::GetCatalogType() {
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresCatalog::CreateSchema(duckdb::CatalogTransaction transaction, duckdb::CreateSchemaInfo &info) {
PostgresCatalog::CreateSchema(duckdb::CatalogTransaction, duckdb::CreateSchemaInfo &) {
throw duckdb::NotImplementedException("CreateSchema not supported yet");
}

duckdb::optional_ptr<duckdb::SchemaCatalogEntry>
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<PostgresTransaction>();
PostgresCatalog::GetSchema(duckdb::CatalogTransaction catalog_transaction, const duckdb::string &schema_name,
duckdb::OnEntryNotFound, duckdb::QueryErrorContext) {
auto &pg_transaction = catalog_transaction.transaction->Cast<PostgresTransaction>();
auto res = pg_transaction.GetCatalogEntry(duckdb::CatalogType::SCHEMA_ENTRY, schema_name, "");
D_ASSERT(res);
D_ASSERT(res->type == duckdb::CatalogType::SCHEMA_ENTRY);
return (duckdb::SchemaCatalogEntry *)res.get();
}

void
PostgresCatalog::ScanSchemas(duckdb::ClientContext &context,
std::function<void(duckdb::SchemaCatalogEntry &)> callback) {
return;
PostgresCatalog::ScanSchemas(duckdb::ClientContext &, std::function<void(duckdb::SchemaCatalogEntry &)>) {
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &context, duckdb::LogicalCreateTable &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) {
PostgresCatalog::PlanCreateTableAs(duckdb::ClientContext &, duckdb::LogicalCreateTable &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
throw duckdb::NotImplementedException("PlanCreateTableAs not supported yet");
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanInsert(duckdb::ClientContext &context, duckdb::LogicalInsert &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) {
PostgresCatalog::PlanInsert(duckdb::ClientContext &, duckdb::LogicalInsert &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
throw duckdb::NotImplementedException("PlanInsert not supported yet");
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanDelete(duckdb::ClientContext &context, duckdb::LogicalDelete &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) {
PostgresCatalog::PlanDelete(duckdb::ClientContext &, duckdb::LogicalDelete &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
throw duckdb::NotImplementedException("PlanDelete not supported yet");
}

duckdb::unique_ptr<duckdb::PhysicalOperator>
PostgresCatalog::PlanUpdate(duckdb::ClientContext &context, duckdb::LogicalUpdate &op,
duckdb::unique_ptr<duckdb::PhysicalOperator> plan) {
PostgresCatalog::PlanUpdate(duckdb::ClientContext &, duckdb::LogicalUpdate &,
duckdb::unique_ptr<duckdb::PhysicalOperator>) {
throw duckdb::NotImplementedException("PlanUpdate not supported yet");
}

duckdb::unique_ptr<duckdb::LogicalOperator>
PostgresCatalog::BindCreateIndex(duckdb::Binder &binder, duckdb::CreateStatement &stmt,
duckdb::TableCatalogEntry &table, duckdb::unique_ptr<duckdb::LogicalOperator> plan) {
PostgresCatalog::BindCreateIndex(duckdb::Binder &, duckdb::CreateStatement &, duckdb::TableCatalogEntry &,
duckdb::unique_ptr<duckdb::LogicalOperator>) {
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");
}

Expand All @@ -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");
}

Expand Down
35 changes: 16 additions & 19 deletions src/catalog/pgduckdb_schema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,81 +12,78 @@ PostgresSchema::PostgresSchema(duckdb::Catalog &catalog, duckdb::CreateSchemaInf
}

void
PostgresSchema::Scan(duckdb::ClientContext &context, duckdb::CatalogType type,
const std::function<void(CatalogEntry &)> &callback) {
return;
PostgresSchema::Scan(duckdb::ClientContext &, duckdb::CatalogType, const std::function<void(CatalogEntry &)> &) {
}

void
PostgresSchema::Scan(duckdb::CatalogType type, const std::function<void(duckdb::CatalogEntry &)> &callback) {
PostgresSchema::Scan(duckdb::CatalogType, const std::function<void(duckdb::CatalogEntry &)> &) {
throw duckdb::NotImplementedException("Scan(no context) not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
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<duckdb::CatalogEntry>
PostgresSchema::CreateFunction(duckdb::CatalogTransaction transaction, duckdb::CreateFunctionInfo &info) {
PostgresSchema::CreateFunction(duckdb::CatalogTransaction, duckdb::CreateFunctionInfo &) {
throw duckdb::NotImplementedException("CreateFunction not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateTable(duckdb::CatalogTransaction transaction, duckdb::BoundCreateTableInfo &info) {
PostgresSchema::CreateTable(duckdb::CatalogTransaction, duckdb::BoundCreateTableInfo &) {
throw duckdb::NotImplementedException("CreateTable not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateView(duckdb::CatalogTransaction transaction, duckdb::CreateViewInfo &info) {
PostgresSchema::CreateView(duckdb::CatalogTransaction, duckdb::CreateViewInfo &) {
throw duckdb::NotImplementedException("CreateView not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateSequence(duckdb::CatalogTransaction transaction, duckdb::CreateSequenceInfo &info) {
PostgresSchema::CreateSequence(duckdb::CatalogTransaction, duckdb::CreateSequenceInfo &) {
throw duckdb::NotImplementedException("CreateSequence not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateTableFunction(duckdb::CatalogTransaction transaction, duckdb::CreateTableFunctionInfo &info) {
PostgresSchema::CreateTableFunction(duckdb::CatalogTransaction, duckdb::CreateTableFunctionInfo &) {
throw duckdb::NotImplementedException("CreateTableFunction not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateCopyFunction(duckdb::CatalogTransaction transaction, duckdb::CreateCopyFunctionInfo &info) {
PostgresSchema::CreateCopyFunction(duckdb::CatalogTransaction, duckdb::CreateCopyFunctionInfo &) {
throw duckdb::NotImplementedException("CreateCopyFunction not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreatePragmaFunction(duckdb::CatalogTransaction transaction, duckdb::CreatePragmaFunctionInfo &info) {
PostgresSchema::CreatePragmaFunction(duckdb::CatalogTransaction, duckdb::CreatePragmaFunctionInfo &) {
throw duckdb::NotImplementedException("CreatePragmaFunction not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateCollation(duckdb::CatalogTransaction transaction, duckdb::CreateCollationInfo &info) {
PostgresSchema::CreateCollation(duckdb::CatalogTransaction, duckdb::CreateCollationInfo &) {
throw duckdb::NotImplementedException("CreateCollation not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::CreateType(duckdb::CatalogTransaction transaction, duckdb::CreateTypeInfo &info) {
PostgresSchema::CreateType(duckdb::CatalogTransaction, duckdb::CreateTypeInfo &) {
throw duckdb::NotImplementedException("CreateType not supported yet");
}

duckdb::optional_ptr<duckdb::CatalogEntry>
PostgresSchema::GetEntry(duckdb::CatalogTransaction transaction, duckdb::CatalogType type,
PostgresSchema::GetEntry(duckdb::CatalogTransaction catalog_transaction, duckdb::CatalogType type,
const duckdb::string &entry_name) {
auto &pg_transaction = transaction.transaction->Cast<PostgresTransaction>();
auto &pg_transaction = catalog_transaction.transaction->Cast<PostgresTransaction>();
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");
}

Expand Down
3 changes: 1 addition & 2 deletions src/catalog/pgduckdb_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
namespace pgduckdb {

static duckdb::unique_ptr<duckdb::TransactionManager>
CreateTransactionManager(duckdb::StorageExtensionInfo *storage_info, duckdb::AttachedDatabase &db,
duckdb::Catalog &catalog) {
CreateTransactionManager(duckdb::StorageExtensionInfo *, duckdb::AttachedDatabase &db, duckdb::Catalog &catalog) {
return duckdb::make_uniq<PostgresTransactionManager>(db, catalog.Cast<PostgresCatalog>());
}

Expand Down
7 changes: 3 additions & 4 deletions src/catalog/pgduckdb_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,18 @@ PostgresHeapTable::PostgresHeapTable(duckdb::Catalog &catalog, duckdb::SchemaCat
}

duckdb::unique_ptr<duckdb::BaseStatistics>
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<duckdb::FunctionData> &bind_data) {
PostgresHeapTable::GetScanFunction(duckdb::ClientContext &, duckdb::unique_ptr<duckdb::FunctionData> &bind_data) {
bind_data = duckdb::make_uniq<PostgresSeqScanFunctionData>(rel, cardinality, snapshot);
return PostgresSeqScanFunction();
}

duckdb::TableStorageInfo
PostgresHeapTable::GetStorageInfo(duckdb::ClientContext &context) {
PostgresHeapTable::GetStorageInfo(duckdb::ClientContext &) {
throw duckdb::NotImplementedException("GetStorageInfo not supported yet");
}

Expand Down
3 changes: 1 addition & 2 deletions src/catalog/pgduckdb_transaction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ PostgresTransactionManager::RollbackTransaction(duckdb::Transaction &transaction
}

void
PostgresTransactionManager::Checkpoint(duckdb::ClientContext &context, bool force) {
return;
PostgresTransactionManager::Checkpoint(duckdb::ClientContext &, bool) {
}

} // namespace pgduckdb
4 changes: 2 additions & 2 deletions src/pgduckdb_background_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
elog(LOG, "started pg_duckdb background worker");
// Set up a signal handler for SIGTERM
pqsignal(SIGTERM, die);
Expand Down Expand Up @@ -98,7 +98,7 @@ pgduckdb_background_worker_main(Datum main_arg) {
ResetLatch(MyLatch);
}

proc_exit(0);
// Unreachable
}

PG_FUNCTION_INFO_V1(force_motherduck_sync);
Expand Down
6 changes: 3 additions & 3 deletions src/pgduckdb_ddl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ DuckdbTruncateTable(Oid relation_oid) {
}

void
DuckdbHandleDDL(Node *parsetree, const char *queryString) {
DuckdbHandleDDL(Node *parsetree, const char *) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we can just remove this argument, since we control the callsite.

if (!pgduckdb::IsExtensionRegistered()) {
/* We're not installed, so don't mess with the query */
return;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/pgduckdb_detoast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ ToastFetchDatum(struct varlena *attr) {

struct varlena *result = (struct varlena *)duckdb_malloc(attrsize + VARHDRSZ);

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
if (VARATT_EXTERNAL_IS_COMPRESSED(toast_pointer)) {
#pragma GCC diagnostic pop
SET_VARSIZE_COMPRESSED(result, attrsize + VARHDRSZ);
} else {
SET_VARSIZE(result, attrsize + VARHDRSZ);
Expand Down
4 changes: 2 additions & 2 deletions src/pgduckdb_metadata_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ uint32 schema_hash_value;
* IsExtensionRegistered for details).
*/
static void
InvalidateCaches(Datum arg, int cache_id, uint32 hash_value) {
InvalidateCaches(Datum, int, uint32 hash_value) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I like this type of change. If we explicitly don't use arguments provided by a hook, I'd like to know what those arguments are used for. Both for reviewing code, but also for when wanting to change behavior of a hook in the future.

if (hash_value != schema_hash_value) {
return;
}
Expand Down Expand Up @@ -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++) {
Expand Down
6 changes: 3 additions & 3 deletions src/pgduckdb_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
DuckdbScanState *duckdb_scan_state = (DuckdbScanState *)cscanstate;
duckdb::unique_ptr<duckdb::PreparedStatement> prepared_query = DuckdbPrepare(duckdb_scan_state->query);

Expand Down Expand Up @@ -226,11 +226,11 @@ Duckdb_EndCustomScan(CustomScanState *node) {
}

void
Duckdb_ReScanCustomScan(CustomScanState *node) {
Duckdb_ReScanCustomScan(CustomScanState *) {
}

void
Duckdb_ExplainCustomScan_Cpp(CustomScanState *node, List *ancestors, ExplainState *es) {
Duckdb_ExplainCustomScan_Cpp(CustomScanState *node, List *, ExplainState *es) {
DuckdbScanState *duckdb_scan_state = (DuckdbScanState *)node;
ExecuteQuery(duckdb_scan_state);

Expand Down
1 change: 1 addition & 0 deletions src/pgduckdb_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ DECLARE_PG_FUNCTION(cache) {
}

DECLARE_PG_FUNCTION(pgduckdb_recycle_ddb) {
(void)fcinfo;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bit silly.

pgduckdb::DuckDBManager::Get().Reset();
PG_RETURN_BOOL(true);
}
Expand Down
Loading
Loading