Skip to content

Commit

Permalink
Add .editorconfig and standardize whitespace (#81)
Browse files Browse the repository at this point in the history
Editorconfig is the standardized configuration file that many editors
as well as GitHub itself use to configure whitespace settings. This
creates this file and aligns files with the new settings.
  • Loading branch information
JelteF authored Aug 2, 2024
1 parent 44a2bb9 commit 1a63a27
Show file tree
Hide file tree
Showing 35 changed files with 79 additions and 51 deletions.
3 changes: 2 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: false
AlwaysBreakTemplateDeclarations: Yes
Language: Cpp
AccessModifierOffset: -4
AccessModifierOffset: -4
InsertNewlineAtEOF: true
27 changes: 27 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# top-most EditorConfig file
root = true

# basic rules for all files
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
indent_size = 4

[*.{c,h,cpp,hpp}]
indent_style = tab

[*.yaml]
indent_size = 2
indent_style = space

[*.sql]
indent_size = 4
indent_style = space

[*.out]
indent_style = unset
indent_size = unset
trim_trailing_whitespace = unset
insert_final_newline = unset
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ compile_commands.json
*.so
*.o
*.bc
*.dylib
*.dylib
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ extern int duckdb_max_threads_per_query;
extern "C" void _PG_init(void);

// pgduckdb_hooks.c
extern void duckdb_init_hooks(void);
extern void duckdb_init_hooks(void);
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_detoast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ namespace pgduckdb {

Datum DetoastPostgresDatum(struct varlena *value, bool *shouldFree);

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_duckdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ extern duckdb::unique_ptr<duckdb::DuckDB> DuckdbOpenDatabase();
extern duckdb::unique_ptr<duckdb::Connection> DuckdbCreateConnection(List *rtables, PlannerInfo *plannerInfo,
List *neededColumns, const char *query);

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ namespace pgduckdb {

bool ApplyValueFilter(duckdb::TableFilter &filter, Datum &value, bool isNull, Oid typeOid);

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_memory_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ void DuckdbFree(duckdb::PrivateAllocatorData *private_data, duckdb::data_ptr_t p
duckdb::data_ptr_t DuckdbReallocate(duckdb::PrivateAllocatorData *private_data, duckdb::data_ptr_t pointer,
duckdb::idx_t old_size, duckdb::idx_t size);

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ extern "C" {
}

extern CustomScanMethods duckdb_scan_scan_methods;
extern "C" void duckdb_init_node(void);
extern "C" void duckdb_init_node(void);
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ typedef struct DuckdbExension {

extern std::vector<DuckdbExension> ReadDuckdbExtensions();

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_planner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ extern "C" {
#include "optimizer/planner.h"
}

PlannedStmt *duckdb_plan_node(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);
PlannedStmt *duckdb_plan_node(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams);
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_process_lock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ struct DuckdbProcessLock {
}
};

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ void ConvertDuckToPostgresValue(TupleTableSlot *slot, duckdb::Value &value, idx_
void InsertTupleIntoChunk(duckdb::DataChunk &output, duckdb::shared_ptr<PostgresScanGlobalState> scanGlobalState,
duckdb::shared_ptr<PostgresScanLocalState> scanLocalState, HeapTupleData *tuple);

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/pgduckdb_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ tokenizeString(char *str, const char delimiter) {
return v;
};

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/scan/heap_reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ class HeapReader {
HeapTupleData m_tuple;
};

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/scan/index_scan_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ extern Node *fix_indexqual_operand(Node *node, IndexOptInfo *index, int indexcol
extern Node *fix_indexqual_clause(PlannerInfo *root, IndexOptInfo *index, int indexcol, Node *clause,
List *indexcolnos);

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/scan/postgres_index_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ struct PostgresIndexScanFunction : public duckdb::TableFunction {
// &function);
};

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/scan/postgres_seq_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ struct PostgresSeqScanFunction : public duckdb::TableFunction {
// &function);
};

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion include/pgduckdb/utility/copy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ extern "C" {
}

extern bool duckdb_copy(PlannedStmt *pstmt, const char *queryString, struct QueryEnvironment *queryEnv,
uint64 *processed);
uint64 *processed);
36 changes: 18 additions & 18 deletions sql/duckdb--0.0.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,72 @@ CREATE OR REPLACE FUNCTION read_parquet(path text)
RETURNS SETOF record LANGUAGE 'plpgsql' AS
$func$
BEGIN
RAISE EXCEPTION 'Function `read_parquet(TEXT)` only works with Duckdb execution.';
RAISE EXCEPTION 'Function `read_parquet(TEXT)` only works with Duckdb execution.';
END;
$func$;

CREATE OR REPLACE FUNCTION read_parquet(path text[])
RETURNS SETOF record LANGUAGE 'plpgsql' AS
$func$
BEGIN
RAISE EXCEPTION 'Function `read_parquet(TEXT[])` only works with Duckdb execution.';
RAISE EXCEPTION 'Function `read_parquet(TEXT[])` only works with Duckdb execution.';
END;
$func$;

CREATE OR REPLACE FUNCTION read_csv(path text)
RETURNS SETOF record LANGUAGE 'plpgsql' AS
$func$
BEGIN
RAISE EXCEPTION 'Function `read_csv(TEXT)` only works with Duckdb execution.';
RAISE EXCEPTION 'Function `read_csv(TEXT)` only works with Duckdb execution.';
END;
$func$;

CREATE OR REPLACE FUNCTION read_csv(path text[])
RETURNS SETOF record LANGUAGE 'plpgsql' AS
$func$
BEGIN
RAISE EXCEPTION 'Function `read_csv(TEXT[])` only works with Duckdb execution.';
RAISE EXCEPTION 'Function `read_csv(TEXT[])` only works with Duckdb execution.';
END;
$func$;

CREATE OR REPLACE FUNCTION iceberg_scan(path text)
RETURNS SETOF record LANGUAGE 'plpgsql' AS
$func$
BEGIN
RAISE EXCEPTION 'Function `iceberg_scan(TEXT)` only works with Duckdb execution.';
RAISE EXCEPTION 'Function `iceberg_scan(TEXT)` only works with Duckdb execution.';
END;
$func$;

CREATE SCHEMA duckdb;
SET search_path TO duckdb;

CREATE TABLE secrets (
type TEXT NOT NULL,
id TEXT NOT NULL,
secret TEXT NOT NULL,
region TEXT,
endpoint TEXT,
r2_account_id TEXT,
CONSTRAINT type_constraint CHECK (type IN ('S3', 'GCS', 'R2'))
type TEXT NOT NULL,
id TEXT NOT NULL,
secret TEXT NOT NULL,
region TEXT,
endpoint TEXT,
r2_account_id TEXT,
CONSTRAINT type_constraint CHECK (type IN ('S3', 'GCS', 'R2'))
);

CREATE OR REPLACE FUNCTION duckdb_secret_r2_check()
RETURNS TRIGGER AS
$$
BEGIN
IF NEW.type = 'R2' AND NEW.r2_account_id IS NULL THEN
Raise Exception '`R2` cloud type secret requires valid `r2_account_id` column value';
END IF;
RETURN NEW;
IF NEW.type = 'R2' AND NEW.r2_account_id IS NULL THEN
Raise Exception '`R2` cloud type secret requires valid `r2_account_id` column value';
END IF;
RETURN NEW;
END;
$$ LANGUAGE PLpgSQL;

CREATE TRIGGER duckdb_secret_r2_tr BEFORE INSERT OR UPDATE ON secrets
FOR EACH ROW EXECUTE PROCEDURE duckdb_secret_r2_check();

CREATE TABLE extensions (
name TEXT NOT NULL,
enabled BOOL DEFAULT TRUE
name TEXT NOT NULL,
enabled BOOL DEFAULT TRUE
);

CREATE OR REPLACE FUNCTION install_extension(extension_name TEXT) RETURNS bool
Expand Down
2 changes: 1 addition & 1 deletion src/pgduckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ duckdb_init_guc(void) {
NULL,
NULL);

}
}
2 changes: 1 addition & 1 deletion src/pgduckdb_detoast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,4 @@ DetoastPostgresDatum(struct varlena *attr, bool *shouldFree) {
return reinterpret_cast<Datum>(toastedValue);
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/pgduckdb_duckdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ DuckdbCreateConnection(List *rtables, PlannerInfo *plannerInfo, List *neededColu
return connection;
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/pgduckdb_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,4 @@ ApplyValueFilter(duckdb::TableFilter &filter, Datum &value, bool isNull, Oid typ
}
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/pgduckdb_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ duckdb_init_hooks(void) {

PrevProcessUtilityHook = ProcessUtility_hook ? ProcessUtility_hook : standard_ProcessUtility;
ProcessUtility_hook = duckdb_utility;
}
}
2 changes: 1 addition & 1 deletion src/pgduckdb_memory_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ DuckdbReallocate(duckdb::PrivateAllocatorData *private_data, duckdb::data_ptr_t
return reinterpret_cast<duckdb::data_ptr_t>(repalloc(pointer, size));
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/pgduckdb_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,4 @@ duckdb_init_node() {
duckdb_scan_exec_methods.ShutdownCustomScan = NULL;

duckdb_scan_exec_methods.ExplainCustomScan = Duckdb_ExplainCustomScan;
}
}
2 changes: 1 addition & 1 deletion src/pgduckdb_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ install_extension(PG_FUNCTION_ARGS) {
PG_RETURN_BOOL(result);
}

} // extern "C"
} // extern "C"
2 changes: 1 addition & 1 deletion src/scan/heap_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,4 @@ HeapReader::ReadPageTuples(duckdb::DataChunk &output) {

return false;
}
} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/scan/index_scan_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ fix_indexqual_clause(PlannerInfo *root, IndexOptInfo *index, int indexcol, Node
return clause;
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/scan/postgres_index_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,4 @@ PostgresIndexScanFunction::PostgresIndexScanCardinality(duckdb::ClientContext &c
return duckdb::make_uniq<duckdb::NodeStatistics>(bindData.m_cardinality, bindData.m_cardinality);
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion src/scan/postgres_seq_scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,4 @@ PostgresSeqScanFunction::PostgresSeqScanCardinality(duckdb::ClientContext &conte
return duckdb::make_uniq<duckdb::NodeStatistics>(bindData.m_cardinality, bindData.m_cardinality);
}

} // namespace pgduckdb
} // namespace pgduckdb
2 changes: 1 addition & 1 deletion test/regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ clean-regression:
rm -fr $(CURDIR)/log
rm -fr $(CURDIR)/results
rm -f $(CURDIR)/regression.diffs
rm -f $(CURDIR)/regression.out
rm -f $(CURDIR)/regression.out
2 changes: 1 addition & 1 deletion test/regression/sql/basic.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ SET duckdb.max_threads_per_query TO default;
SET client_min_messages TO default;

DROP TABLE t;
DROP TABLE empty;
DROP TABLE empty;
2 changes: 1 addition & 1 deletion test/regression/sql/materialized_view.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ SELECT COUNT(*) FROM t WHERE (a % 100 = 0) AND (a < 30);
SELECT COUNT(*) FROM tv WHERE a < 30;

DROP MATERIALIZED VIEW tv;
DROP TABLE t;
DROP TABLE t;

0 comments on commit 1a63a27

Please sign in to comment.